Obsolete Pages{{Obsolete}}
The official documentation is at: http://docs.alfresco.com
LoggingDebuggingConfiguration
Back to Server Configuration
This is a brief tutorial on configuring Log4J via the log4j.properties (or log4j.xml) file.
- Log categories inherit their log level if it has not been explicitly set.
- All log levels are DEBUG be default including the root category, which is implicit.
- Once the log messages have been created, they are sent to appenders that have their own output thresholds defined.
Example 1 (BAD)
- The root category defaults to DEBUG
- Categories that have not had their log level set will inherit their log level from the root, which is set to DEBUG
- In code, the isDebugEnabled() call for category org.alfresco will always return true
- The log output will only be dumped to file if the level is ERROR or higher
...
<param name='Threshold' value='ERROR'/>
...
</appender>
<root>
<appender-ref ref='FILE'/>
</root>
...
Example 2 (GOOD)
- The root category has been explicitly set to ERROR
- Categories that have not had their log level set will inherit their log level from the root, which is set to ERROR
- In code, the isDebugEnabled() call for category org.alfresco will return false
- The log output will only be dumped to file if the level is DEBUG or higher
...
<param name='Threshold' value='DEBUG'/>
...
</appender>
<root>
<priority value='ERROR' />
<appender-ref ref='FILE'/>
</root>
...
Selective debugging
Using example 1 you can only switch off debugging selectively, which means that you have to actively set a log level for each and every logging category that comes along. This is impractical and leads to costly debug strings being created even though the appenders filter them out. In most cases, the creation of the debug strings is costly and in the worst case contains bugs.
By using example 2 all debugging is disabled, but the appenders will allow debug messages to be output if they have been enabled for a category.
To enable VM summary performance debugging add the following:
...
<category name='performance'>
<priority value='DEBUG'/>
</category>
<category name='performance.summary.method'>
<priority value='ERROR'/>
</category>
...
You can also turn on all class debugging for org.alfresco using:
...
<category name='org.alfresco'>
<priority value='DEBUG'/>
</category>
...
Axis, Hibernate, Quartz and Spring
These components use commons-logging.
If you want to see logging from these components, you may need a commons-logging.properties set up to point to log4J.
See also
See also AMP and log4j.properties which contains information on configuring log4j which is relevant even if you aren't packaging an AMP module.