Formatter for JUL (java.util.logging) which produce ECS-compatible records. May be useful for applications which use JUL as primary logging framework (e.g. Apache Tomcat).
Add a dependency to your application
<dependency>
<groupId>co.elastic.logging</groupId>
<artifactId>jul-ecs-formatter</artifactId>
<version>${ecs-logging-java.version}</version>
</dependency>
If you are not using a dependency management tool, like maven, you have to add both, jul-ecs-formatter
and ecs-logging-core
jars manually to the classpath. For example to the $CATALINA_HOME/lib
directory.
Specify co.elastic.logging.jul.EcsFormatter
as formatter
for the required log handler.
For example $CATALINA_HOME/conf/logging.properties
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = co.elastic.logging.jul.EcsFormatter
co.elastic.logging.jul.EcsFormatter.serviceName=my-app
Parameter name | Type | Default | Description |
---|---|---|---|
serviceName | String | Sets the service.name field so you can filter your logs by a particular service |
|
eventDataset | String | ${serviceName}.log |
Sets the event.dataset field used by the machine learning job of the Logs app to look for anomalies in the log rate. |
stackTraceAsArray | boolean | false |
Serializes the error.stack_trace as a JSON array where each element is in a new line to improve readability. Note that this requires a slightly more complex Filebeat configuration. |
includeOrigin | boolean | false |
If true , adds the log.origin.file.name , log.origin.file.line and log.origin.function fields. Note that JUL does not stores line number and log.origin.file.line will have '1' value. |