Logging
This section describes how logging works in the solution.
The solution uses the Log4j2 library to manage logging. Each component of the solution has different loggers. The configuration file is located in the [installation directory]/etc folder and is called log4j2.xml.
Server Logging
For the server, by default, the application comes with several loggers:
- wrapper-log : logger that captures the application console messages.
- server-log : logger that writes what happens on the server.
- extension-log : logger that writes what happens during the execution of various extensions.
- audit-log : logger that writes different audit events.
- transfer-log : logger that writes file transfers.
- task-log : logger that writes the current state of the task scheduler.
- configurator-log : logger that writes the Administrative Console events.
Gateway Logging
For the gateway, by default, the application comes with several loggers:
- gateway-log : logger that writes what happens on the gateway.
- gui-log : logger that writes what happens in the web interface.
Request Correlation
Every HTTP request handled by the server, the web interface or the gateway runs under a request identifier. The identifier is written to the MDC_REQUEST_ID field of the log pattern (%X{MDC_REQUEST_ID}) and to the trace.id field of the ECS (Elastic Common Schema) logs. Every log entry written while the request is processed carries this identifier, so you can follow a single request across the gateway, web interface and server logs by searching for it.
The identifier comes from the X-REQUEST-ID request header when the caller sends a valid value, and is generated otherwise. An invalid value is never written to the logs. The rules of the header and the identifier returned in the response are described in Request Correlation of the REST API guide.
Each component can also log every incoming request, with its method, URI, listening port and request identifier. These entries are written at the DEBUG level, which the default configuration does not enable. To turn them on, add the following logger to the log4j2.xml file of the component:
<Logger name="com.okiok.sfiler.utils.web.filter.MdcClearFilter" level="DEBUG"/>Each command run by the CLI (sfiler), the Administration CLI (sfiler-admin) and the Configuration CLI (sfiler-config-cli) also gets its own identifier. With the Administration CLI and the Configuration CLI, every line of a script (-x) gets its own identifier too.
- The CLI and the Administration CLI send the identifier to the server in the
X-REQUEST-IDheader, so a command can be followed into the server logs. In verbose mode (-v), they display it on the console asOperation ID: <identifier>. The CLI writes no log file, so the console is the only place where its identifier appears. - The Administration CLI (when
-logis used) and the Configuration CLI write the identifier in their own log entries, between brackets after the logger name.
Using the Elastic Common Schema (ECS) Format
Available in4.20.7 +
It is possible to use the ECS (Elastic Common Schema) format. This improvement is designed to modernize how logs are collected, analyzed, and used, providing you with better visibility into your application's performance and events. Note that it is entirely possible to use both the traditional logging system and the new ECS-based system in parallel.
Warning
To easily configure ECS logging in on-prem instances, S-Filer Portal now includes a new Log4J configuration file named: log4j2.ecs.xml for each component. To use it, backup the regular log4j2.xml file and rename log4j2.ecs.xml to log4j2.xml.
SaaS instances are already configured to send logs to OKIOK's SIEM solution, if you need to send logs to an external SIEM solution contact OKIOK support.
What is the ECS format?
The ECS format is an open specification that provides a common set of data fields for logging. By relying on this standardized schema, all types of log data (application logs, metrics, security events) can be structured consistently.
The benefits:
Simplified analysis and correlation: The ECS format eliminates the complexity of log analysis by ensuring that critical data such as timestamps, severity levels, messages, and exception information are always located at the same standard positions. This facilitates aggregation, search, and analysis of your logs, regardless of their type or source.
Seamless integration with the Elastic ecosystem: If you use tools like Elasticsearch, Kibana, or Elastic Stack, adopting the ECS format will allow you to benefit from almost instant plug-and-play integration. You will thus be able to use advanced visualization, search, and analysis features without having to configure complex ingestion pipelines.
Improved visibility and problem resolution: By normalizing the structure of your logs, it becomes much simpler to correlate events that come from different parts of your system. For example, you can quickly link a security event to a specific application log or performance trace, thus accelerating problem detection and resolution.
Here is an example of a Log4j.xml file that allows generating logs in ECS format:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorinterval="30" status="info" strict="true">
<Appenders>
<RollingFile name="server-log" fileName="logs/server.jsonl" filePattern="logs/server-%d{yyyy-MM-dd}.jsonl">
<JsonTemplateLayout eventTemplateUri="classpath:sfiler-ecs-layout.json"/>
<Policies>
<SizeBasedTriggeringPolicy size="256MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
<!-- The logger for the Task Logger. This is a dedicated logger to have a view over the pending Tasks to be executed. -->
<RollingFile name="task-log" fileName="logs/tasks.log" filePattern="logs/tasks-%d{yyyy-MM-dd}.log">
<ThresholdFilter level="DEBUG"/>
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss},%m%n"/>
<Policies>
<SizeBasedTriggeringPolicy size="1000KB"/>
</Policies>
<DefaultRolloverStrategy max="100"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="server-log"/>
</Root>
<!-- Common loggers used in S-Filer that may have levels different than the root -->
<Logger name="extlogger" level="INFO"/>
<Logger name="AUDIT" level="INFO"/>
<!-- The logger for the TransferLogging extension. It was previously defined in its own configuration file in the etc/extension folder. -->
<Logger name="com.sfiler.extension.commons.TransferLoggingExtension" level="INFO"/>
<!-- The logger for the Task Logger. This is a dedicated logger to have a view over the pending Tasks to be executed. -->
<Logger name="task-log" level="DEBUG" additivity="false">
<AppenderRef ref="task-log"/>
</Logger>
<!-- log4jdbc2 logger -->
<logger name="log4jdbc.log4j2" level="OFF">
<MarkerFilter marker="LOG4JDBC_OTHER" onMatch="DENY" onMismatch="NEUTRAL"/>
</logger>
<!-- other loggers -->
<Logger name="org.apache.axis.enterprise" level="INFO"/>
<Logger name="net.sf.jasperreports.engine.util.JRStyledTextParser" level="OFF"/>
<logger name="liquibase.executor.jvm.JdbcExecutor" level="OFF"/>
<Logger name="com.azure.core.util.serializer.SerializerEncoding" level="OFF"/>
</Loggers>
</Configuration>