• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

log4j refuses to write to file

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.

After working in several projects where log4j was in place before i got there, i ended up building a project from scratch that will use log4j. I have as Maven dependency to log4j version 1.2.14. I set up some logging and after reading the online documentation, i ended up copying a log4j.properties file from there. It looks like this:


Now when i run my application (in OC4J) i can see my logging in the console, but the "mylogfile.log" file is never created. I verified that the properties file is indeed the one used by changing the logging layout and checking the results in the console output.

Can anyone out there help me figure out why the appender is not working?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried using an absolute path and checking that location? Is there anything in the log on startup indicating a configuration error?
 
Mats Andersson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Have you tried using an absolute path and checking that location? Is there anything in the log on startup indicating a configuration error?



Yes, i tried that too. No log file.

Nothing in any log file indicates any problems with log4j... :confused:
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see anything wrong with it, and the exact same config file (but with an absolute path) works fine for me (although I've wrapped it with Commons Logging, the underlying Log4J config is what's used):And in the log file:
 
Mats Andersson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hang on a second! After setting the log level down to WARN, this error message was no longer lost by overflow in my command prompt:



My log4j.properties file had this setting:


 
Mats Andersson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And switching from backslash to slash (which i assume is correct) gives this error message:



So this is an access rights problem? OC4J doesn't have the rights to write to disk?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try writing to a non-root directory?
 
Mats Andersson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Try writing to a non-root directory?



It doesn't seem to matter at all where try to place the log files.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you're missing the appropriate rights to write in these folders. Are you perhaps using Vista? Vista is a real pain when it comes to writing to the C: drive, with its annoying UAC.
 
Mats Andersson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:It looks like you're missing the appropriate rights to write in these folders. Are you perhaps using Vista? Vista is a real pain when it comes to writing to the C: drive, with its annoying UAC.



Windows 7.

I tried writing the logs in my user folder too, but that didn't work either.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you running the server?
 
Mats Andersson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:How are you running the server?



By double-clicking on a cmd file that does: C:\oracle\oc4j\bin\oc4j.cmd -start
 
Mats Andersson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved this. Found the log files in the folder where i have the bat-file that starts OC4J. Not the most logical place to me, but at least it's solved. Thanks for trying to help, guys.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually it is the most logical place. Your file location is relative in the configuration file, which means it's relative to the current working directory when the JVM is started.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic