1. If possible run with -Dlo4j.debug in the command that starts Java.
That will cause log4j to print into to std out about how it is
configured.
2. By "go about using the logger" I assume, you mean creating logs.
In every class where you want logging, add "Logger logger =
Logger.getLogger(getClass());" The name calls to logger.debug,
logger.info, etc.
Example:
logger.debug("About to do something");
try {
logger.info("Tada!";
...
} catch(FileNotFoundException e) {
logger.error("Unable to ...", e);
}
On 12/14/06, Adam K <[EMAIL PROTECTED]> wrote:
I'm using this but I have 2 questions (yet again).
1) How do I know if the class is being picked up properly, as I don't see
any errors in the logs files
2) How do I go about using the logger within the application - that is how
do I get a handle to it ?
again thanks for all the help.
On 12/14/06, James Stauffer <[EMAIL PROTECTED]> wrote:
>
> If you name your file "log4j.xml" and if is accessible in the
> classpath (i.e. WEB-INF/classes), then log4j will automatically find
> it and configure itself with it.
>
> On 12/14/06, Adam K <[EMAIL PROTECTED]> wrote:
> > See the "Default Initialization Procedure" section at
> > http://logging.apache.org/log4j/docs/manual.html
> >
> > I have looked at this, but am now more confused than previously. (Part
> of
> > the problem is that I tried to use parts for that page which obviously
> > resulted in disaster.
> >
> > I was looking around and found the following:
> >
>
http://mail-archives.apache.org/mod_mbox/logging-log4j-user/200207.mbox/[EMAIL
PROTECTED]
> >
> > and would like to clarify the steps that I should be following (thanks
> for
> > your patience with me on this one).
> >
> > 1) add log4j.jar to WEB-INF/lib/ -- COMPLETE
> > 2) create a log4jConfiguration.xml file and place it in
> /WEB-INF/src/java/
> > ------COMPLETE When compiled the file is appearing under
> /WEB-INF/classes
> >
> > The following is the xml file
> >
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> >
> > <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
> > <appender name="console" class="org.apache.log4j.ConsoleAppender">
> > <param name="Target" value="System.out"/>
> > <layout class="org.apache.log4j.PatternLayout">
> > <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
> > </layout>
> > </appender>
> >
> > <root>
> > <priority value ="debug" />
> > <appender-ref ref="console" />
> > </root>
> >
> > </log4j:configuration>
> >
> > At this point I am wondering if I should be doing something similar to
> what
> > is mentioned in the e-mail archive that I borrowed. Again if you can
> advise
> > me I would really appreciate it.
> >
> > thanks again for your time and effort.
> >
> >
>
>
> --
> James Stauffer http://www.geocities.com/stauffer_james/
> Are you good? Take the test at http://www.livingwaters.com/good/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
James Stauffer http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]