Package org.logevents.observers
Class ConsoleLogEventObserver
- java.lang.Object
-
- org.logevents.core.AbstractFilteredLogEventObserver
-
- org.logevents.observers.ConsoleLogEventObserver
-
- All Implemented Interfaces:
LogEventObserver
public class ConsoleLogEventObserver extends AbstractFilteredLogEventObserver
Log messages to the system out with suitable formatter. Ansi colors will be used if running on a non-Windows shell or if JANSI is in class path. (Color on Windows is supported in IntelliJ, Cygwin and Ubuntu for Windows).Example configuration (not usually needed, default configuration should serve most purposes)
observer.console.threshold=WARN observer.console.outputToSyserr=true observer.console.includedMdcKeys=clientIp observer.console.suppressMarkers=UNINTERESTING, PERSONAL_DATA observer.console.packageFilter=sun.www, com.example.uninteresting observer.console.logFilenameForPackages=com.example.myapp
To add custom pattern format to the observer (shorthand for ...formatter=PatternLogEventFormatter and ...formatter.pattern=...):observer.console.pattern=%time [%thread] [%coloredLevel] [%bold(%location)]%mdc: %message
To override ANSI formatting inConsoleLogEventFormatter
, use:observer.console.formatter.colors=false
- Author:
- Johannes Brodwall
-
-
Constructor Summary
Constructors Constructor Description ConsoleLogEventObserver()
ConsoleLogEventObserver(Map<String,String> properties, String prefix)
ConsoleLogEventObserver(Configuration configuration)
ConsoleLogEventObserver(LogEventFormatter formatter)
ConsoleLogEventObserver(LogEventFormatter formatter, PrintStream out)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doLogEvent(LogEvent logEvent)
LogEventFormatter
getFormatter()
String
toString()
-
Methods inherited from class org.logevents.core.AbstractFilteredLogEventObserver
configureFilter, filteredOn, getCondition, getThreshold, isEnabled, logEvent, setCondition, setFilter, setThreshold, shouldLogEvent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.logevents.LogEventObserver
isEnabled, stream, toList
-
-
-
-
Constructor Detail
-
ConsoleLogEventObserver
public ConsoleLogEventObserver(LogEventFormatter formatter, PrintStream out)
-
ConsoleLogEventObserver
public ConsoleLogEventObserver(LogEventFormatter formatter)
-
ConsoleLogEventObserver
public ConsoleLogEventObserver()
-
ConsoleLogEventObserver
public ConsoleLogEventObserver(Configuration configuration)
-
-
Method Detail
-
getFormatter
public LogEventFormatter getFormatter()
-
doLogEvent
protected void doLogEvent(LogEvent logEvent)
- Specified by:
doLogEvent
in classAbstractFilteredLogEventObserver
-
-