Link

How to activate debug logs ?

Ariel Cohen - on 2/10/06 at 11:16 AM

I am developing a custom DataController for a project and I am trying to use debug logging but nothing appears neither in jcms nor in tomcat logs file...

Can you help me?

Ariel Cohen - on 2/10/06 at 11:31 AM

I try to add those lines on log4j.xml :

  <logger name="ProjectContentController">
    <level value="DEBUG" /> 
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="LOGFILE" />
  </logger>

but it doesn't works..

Olivier Jaquemet - on 2/10/06 at 11:38 AM

Initialize a Logger in your Class:

  private static final Logger logger = 
               Logger.getLogger(MyController.class);

In the file WEB-INF/data/log4j.xml, precise the level of logging you would like for this logger :

   <logger name="custom.MyController">
      <level value="DEBUG" />
   </logger>

If your class is not in a predefined logger of jcms ("custom", "generated", "com.jalios" or "jsp") you also need to precise in this file what appenders you want to use for this logger. For example, if your package is "com.cohen":

  <logger name="com.cohen" additivity="false">
    <level value="INFO" />
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="LOGFILE" />
  </logger>

Should you need further informations, we have written an article to help you getting started with log4j inside JCMS. Unfortunately it is currently only available in french:
JCMS 5 : La journalisation des évènements avec log4j

Though here is a rough translation of this article in english using google translate.

Ariel Cohen - on 2/10/06 at 11:52 AM

Thanks! It's working now! I had just written "<logger name="ProjectContentController">" instead of "<logger name="custom.ProjectContentController">"... Sorry ;)

Do I need to add some "appender" tag in the logger? They are present in the standard loggers but not in the examples.

Olivier Jaquemet - on 2/10/06 at 12:11 PM

No.

Appenders are ways of outputting logging events using log4j.
The <appender...> tag is where you define those appenders.

For example, in the default log4j.xml file of JCMS, we define two appenders: "CONSOLE", and "LOGFILE", which respectively output to the java console and to the jcms log file (WEB-INF/data/logs/jcms.log).

Once appenders have been declared, we can use/reference them in the loggers using the <appender-ref...> tag.
That's what we do in the main declaration of the loggers:

  <logger name="com.jalios">
    <level value="INFO" /> 
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="LOGFILE" />
  </logger>

But because appenders are inherited in the loggers hierarchy, you only need to precise them once.
For example, if you have defined the main logger hierarchy "com.cohen" with the appenders CONSOLE and LOGFILE with the logging level INFO:

  <logger name="com.cohen">
    <level value="INFO" /> 
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="LOGFILE" />
  </logger>

And that you just want MyController logger to have the DEBUG logging level, you just need to precise this afterwards:

  <logger name="com.cohen.MyController">
    <level value="DEBUG" /> 
  </logger>
Login   Home   fr en
JALIOS SA - SIREN 440 126 035