This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
What I really want to do is write a diagnostic line to a text file. With the maligned System.out.println() it's drop dead easy and I'm on to another task. My app is a web service running in axis2, which is in Tomcat container, which is in Jetspeed, to make things interesting...
I included the typical
At the top. I can log messages. To the console. I tried making them log to a file with
in the log4j.properties file and no file was created. I no longer logged to the console, but I saw no log file either.
The config file says the log file should be
How can I log to a file, and in which directory will the log file appear?
Tony Ennis wrote:So I suppose my frustration deals with the config file and the sinking feeling I get when I make a change and ... nothing changes.
I've search a large amount of my hard drive. I don't see the log file anywhere.
I don't see the line(s) that tell log4j to write the file. I find the standard documentation very frustrating, so I'm on the log4j mailing list.
but I don't see where rootCategory is defined.
In addition to weak documentation, log4j fails silently, so if you have any problems, it doesn't tell you.
I'll past my working file as a guide
Joined: May 22, 2003
There's nothing else in the file that refers to rootCategory.
There is a section for LOGFILE
But this looks boilerplate.
I frankly think Java & Co. is needlessly complex. It seems everything beyond "hello world" needs some arcane xml file located in some mysterious location. The amount of research necessary before I can write a line to a file amazes me.
Tony Ennis wrote:I frankly think Java & Co. is needlessly complex. It seems everything beyond "hello world" needs some arcane xml file located in some mysterious location.
To be accurate, Java is a very simple language that can be completely described in a very thin book.
And the standard Java logging tools are easy to use and take no configuration.
log4j is designed to be flexible and allow dynamic changes. This is what you want for a huge webapp that is deployed on redundant servers, made of parts from here and there. That functionality requires configuration stuff. Granted, the log4j configuration is not obvious, but it is extremely powerful.
If you don't need the power of log4j, don't use it. Use the standard Java JDK logger instead.
Joined: May 22, 2003
Yes, its bolierplate, but with nothing else refering to the keyword, one would expect nothing to happen with it
Well, it isn't inert, it is logging or not logging to the console, so *something* is making this happen. Perhaps some other config file is including this one.