View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

How To Configure Log

Bulbgraph.png   log4j2 is introduced in Openbravo since PR19Q1. If you're using a previous version of Openbravo, please refer to How_To_Configure_Log_Using_Log4j1.x to configure log using log4j 1.x.

Contents

Introduction

Logging allows developers to insert messages when code is executed, these messages can be used to understand different issues in the backend code, such as errors, performance problems, etc.

Starting from PR19Q1, Openbravo uses log4j2 to log.

Configuration

Logging is configured using 3 log configuration files, depending on the scenario:

File

Typically log is redirected to a file. This file is determined by the <RollingFile> tag inside the <Appenders> section. The defaults are:

<RollingFile name="RollingFile" fileName="${logDir}/openbravo.log"
             filePattern="${logDir}/openbravo-%d{yyyyMMdd}-%i.log.gz">
<PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
  <Policies>
    <TimeBasedTriggeringPolicy />
    <SizeBasedTriggeringPolicy size="100MB" />
  </Policies>
  <DefaultRolloverStrategy max="30"/>
</RollingFile>

With this configuration, regular log will be placed in openbravo.log file in tomcat's log directory.

Log Verbosity

Verbosity in the log is defined by the log levels:

ALL TRACE DEBUG INFO WARN ERROR FATAL OFF

Developer decides which is the level of each of the messages sent to the log.

It is possible to configure the log to display messages starting from any of these levels. Default configuration shows INFO and above. Log level can be configured globally and/or per class/package.

This can be modified in 2 ways:

<Loggers>
  <!-- Setting default log level as debug -->
  <Root level="debug">
  ...
  </Root>
  ...
</Loggers>
<Loggers>
  ...
  <!-- Setting your.path.here logger to debug level -->
  <!-- your.path.here can refer either to a class or a package fully qualified name -->
  <Logger name="your.path.here" level="debug"/>
  ...
</Loggers>
Bulbgraph.png   Note that this logger will inherit the appenders used by the parent logger (Root in most cases). If you want to change this behavior, you should add the additivity attribute and set it to false. See Log4j2 documentation for more details.

Logmanagement.png

Rotation

In order to prevent log file to constantly increase, rotation is defined. Rotation sets up the policy to decide when log file will be archived and how many archives will be maintained.

It is configured with the following properties in <RollingFile> section:

<Policies>
  <TimeBasedTriggeringPolicy />
  <SizeBasedTriggeringPolicy size="100MB" />
</Policies>
<DefaultRolloverStrategy max="30"/>

By default, log file is limited to 100MB size and will be archived and compressed daily and/or when log exceeds 100MB. The number of log files stored is limited to 30 and when exceeded the older one will be removed.

For more info about the Rolling File Appender see Log4j2 documentation.

Upgrade from previous versions

In order to fully support log4j2 when migrating from an older version (18Q4 or lower), the following steps should be taken:

ant setup -DnonInteractive=yes -DacceptLicense=yes
Bulbgraph.png   If using Java 11, you must add an option to ANT_OPTS in order to build Openbravo. See [2] for details.

Retrieved from "http://wiki.openbravo.com/wiki/How_To_Configure_Log"

This page has been accessed 20,474 times. This page was last modified on 8 January 2019, at 13:02. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.