Re: Hmm, not understanding log4j properly :(
- From: "Stefan Siegl" <s.siegl@xxxxxxxxxxxxxxx>
- Date: Fri, 7 Oct 2005 15:21:30 +0200
"Pep" <pep@xxxxxxxxxxx> wrote in message
news:di5pjk$jpm$1@xxxxxxxxxxxxxxxxxxxxxxx
> I have these 2 lines of code in my test program
>
> private static final Category log = Category.getInstance("TEST");
> PropertyConfigurator.configure("TestOutputFile");
>
> and I thought after reading the documentation that this would open a
output
> file called testOutputFile which log4j would then store the results in
> using the following line of code
>
> log.info(message);
>
> except that I get this error message
[...]
> which indicates that
> PropertyConfigurator.configure("TestOutputFile");
> is actually looking to open this file for reading?
Right. This is because, PropertyConfigurator.configure() will try to setup
the log4j system. As the documentation of the method (public static void
configure(String configFilename)) suggests, the path that you have to
provide is the path to the configuration file and not the path to the file
you want your log information to be logged to. Log4j decouples the process
of logging (e.g. log.info()) with the reaction to the logging (e.g. writing
sth to a file). The reaction has to be defined within the configuration
file. Log4j reads the configuration file and decides what should be done
with logged information. For example you might have multiple appenders (e.g.
one writing to a file and one to the console), with different layouts (e.g.
the console only displays the time and the message, whereas the file logging
should also provide the name of the class that logged the message).
> Can anyone tell me what I need to do as I am somewhat confused by the
> documentation?
Try to define a properties file containing the configuration of log4j (here
is a description: http://www.vipan.com/htdocs/log4jhelp.html). Let me know
if you need more help
hth,
Stefan
.
- References:
- Hmm, not understanding log4j properly :(
- From: Pep
- Hmm, not understanding log4j properly :(
- Prev by Date: Re: eclipse 2x mark occurrences
- Next by Date: Re: JNI noob question, and the whole thing too
- Previous by thread: Hmm, not understanding log4j properly :(
- Next by thread: Re: How to check if server closed connection?
- Index(es):
Relevant Pages
|
|