ConsoleWriter
, FileWriter
, JdbcWriter
, LogcatWriter
, RollingFileWriter
, SharedFileWriter
public interface Writer
Logger
.
The annotation PropertiesSupport
must be added to the implemented
writer class and the implemented writer must be registered as service in "META-INF/services/org.pmw.tinylog.writers"
in order to make the writer available by properties files and system properties.
Example:
@PropertiesSupport(name = "example",
properties = { @Property(name = "filename", type = String.class), @Property(name = "backups", type = int.class) })
public final class ExampleWriter implements Writer {
A writer must have a constructor that matches to the defined properties.
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Close the writer and release all resources.
|
void |
flush() |
Flush this writer and force any buffered data to output.
|
Set<LogEntryValue> |
getRequiredLogEntryValues() |
Get all log entry values that are required by this writer.
|
void |
init(Configuration configuration) |
Initialize the writer (open a file for example).
|
void |
write(LogEntry logEntry) |
Write a log entry.
|
Set<LogEntryValue> getRequiredLogEntryValues()
void init(Configuration configuration) throws Exception
configuration
- Configuration of loggerException
- Failed to initialize the writervoid write(LogEntry logEntry) throws Exception
logEntry
- Log entry to outputException
- Failed to write the log entryvoid flush() throws Exception
Exception
- Failed to flushvoid close() throws Exception
close()
call, it should be
registered in the init()
method at VMShutdownHook
for
automatically shutdown when VM will be shutdown.Exception
- Failed to close the writerCopyright © 2019. All rights reserved.