7

From question Problem adding a custom REL tag handler

"...if anybody knows what needs to be done to enable logging to the standard tridion logs (cd_core.log etc), it would be nice to know."

7

Fist of all you need a proper logback.xml, see this one logback.xml for an example. You can and should use Logback in your own code as well. Note the custom appender and logger in this example.

Also you need the Logback JARs (based on SDL Tridion 2011 / SDL Tridion 2013)

  • logback-classic.jar
  • logback-core.jar
  • slf4j-api.jar
  • jcl-over-slf4j.jar (I am not sure why)

If you add all of the third library JARs from the Tridion install media (API role) to your project the JARs above should be there. When trying to have a minimal set of third party libraries you could end up with only the slf4j-api.jar since you will get errors when you miss those. By adding the other JARs your web application actually has the logging framework and the implementation to write it to the filesystem.

If you see exceptions like

... Caused by: java.lang.NoClassDefFoundError: Lorg/slf4j/Logger

or

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation

you know you are missing some of the JARs.

1
3

In addition to Jan's suggestion, the common mistake that I have experienced is the level of root being set to OFF or your desired logger is not part of it.

Considering the logback.xml mentioned in the above answer posted by Jan, consider the below block:

<root level="OFF">
<appender-ref ref="rollingCoreLog"/>
</root>

If the level="OFF", none of the log will get generated and to generate logs identified by rollingCoreLog

<root level="OFF">
<appender-ref ref="rollingCoreLog"/>
</root>

In addition, if you want any additional logs to get generated - For example - Deployer and Transport Logs, you need to mentioned the corresponding identified in this block as shown below:

<root level="OFF">
<appender-ref ref="rollingCoreLog"/>
<appender-ref ref="rollingDeployerLog"/>
<appender-ref ref="rollingTransportLog"/>  
</root>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.