User Tools

Site Tools


tools:logger:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tools:logger:start [2026/04/13 10:20] – [Multiple Destinations] ursgraftools:logger:start [2026/04/13 11:12] (current) – [Adding Output to the SysLog] ursgraf
Line 49: Line 49:
 A log file will be created at the given location. Its file name will be appended with the current date and time of the creation of the file. A log file will be created at the given location. Its file name will be appended with the current date and time of the creation of the file.
  
-===== Multiple Destinations =====+===== Adding Output to the SysLog =====
 The simplest way to attach a second sink is via Logger::addWriter(), which promotes the existing writer into a MultiLogWriter automatically: The simplest way to attach a second sink is via Logger::addWriter(), which promotes the existing writer into a MultiLogWriter automatically:
  
 <code cpp> <code cpp>
-  Logger::setDefaultStreamLogger(std::cout, "myLog");+  Logger::setDefaultStreamLogger(std::cout, "/tmp/myLog");
   Logger::addWriter(std::make_shared<SysLogWriter>("myLog"));   Logger::addWriter(std::make_shared<SysLogWriter>("myLog"));
   auto log = Logger::getLogger('A');   auto log = Logger::getLogger('A');
Line 63: Line 63:
    
 <code cpp> <code cpp>
 +  #include <eeros/logger/MultiLogWriter.hpp>
 +
   auto multi = std::make_shared<MultiLogWriter>();   auto multi = std::make_shared<MultiLogWriter>();
-  multi->add(std::make_shared<StreamLogWriter>(std::cout, "myLog"));+  multi->add(std::make_shared<StreamLogWriter>(std::cout, "/tmp/myLog"));
   multi->add(std::make_shared<SysLogWriter>("myLog"));   multi->add(std::make_shared<SysLogWriter>("myLog"));
   Logger::setDefaultWriter(multi);   Logger::setDefaultWriter(multi);
 +</code>
 +
 +View the produced log entries in the system log with 
 +<code bash>
 +$ journalctl -t myLog
 </code> </code>
tools/logger/start.1776068427.txt.gz · Last modified: by ursgraf