This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

log4j log file not created

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my log4j.xml and I want to create a log file wws.log either in a folder where folder path = AE_HOME/logs/ where AE_HOME = "C:/AE/" and AE_HOME is set as a system variable by another program already.



I also tried using env:AE_HOME in the file path but still I dont find the log file getting generated anywhere. I tried hard coding the path too, but still no log file. I have permission to write in the C drive so that's not an issue.

This is where the logger is being setup in the ServletInit class:



Is there something I am doing wrong?

Please advise.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What output comes from running the program?

Does it come out with the "Initializing log4j..." message?
 
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

... and AE_HOME is set as a system variable by another program already



Set by another program? You're going to have to post more details to explain how setting the system variable in that other program causes the system variable to be set to the same value in this program. (My suspicion is that it doesn't cause any such thing.)
 
Sheriff
Posts: 4673
308
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have configured a log4j 'appender' which defines how to publish log messages, but you have not configured a 'category' which defines when to publish messages.

 
Prathy Maroor
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stefan Evans wrote:What output comes from running the program?

Does it come out with the "Initializing log4j..." message?



Yes, it says initializing log4j.
 
Prathy Maroor
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Cooke wrote:You have configured a log4j 'appender' which defines how to publish log messages, but you have not configured a 'category' which defines when to publish messages.



Even without the category, I see the log file being generated when the param name="File" value="wws.log" (this works only when I run on Eclipse. and the log file is generated in the eclipse folder). I want to be able to place the log file in a specific folder and that's what is giving me trouble.
 
Prathy Maroor
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:

... and AE_HOME is set as a system variable by another program already



Set by another program? You're going to have to post more details to explain how setting the system variable in that other program causes the system variable to be set to the same value in this program. (My suspicion is that it doesn't cause any such thing.)



There is another exe that is run before installing my webapp war file. That exe sets the system variable AE_HOME. I would like to use that to put my logs.
 
Tim Cooke
Sheriff
Posts: 4673
308
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prathy Maroor wrote:Even without the category, I see the log file being generated when the param name="File" value="wws.log"


What? But you just said earlier:

Prathy Maroor wrote:I tried hard coding the path too, but still no log file


Which is it?

With regards to your other application setting the System var AE_HOME, I am in agreement with Paul and I suspect that your other application is only setting the System var for its particular terminal session and is not setting the System var for the terminal session you are running this application in. I'm not a Windows expert, but if you give us some more details about how this other application is operating then I'm sure you'll get more help on that.
 
Prathy Maroor
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Cooke wrote:

Prathy Maroor wrote:Even without the category, I see the log file being generated when the param name="File" value="wws.log"


What? But you just said earlier:

Prathy Maroor wrote:I tried hard coding the path too, but still no log file


Which is it?

With regards to your other application setting the System var AE_HOME, I am in agreement with Paul and I suspect that your other application is only setting the System var for its particular terminal session and is not setting the System var for the terminal session you are running this application in. I'm not a Windows expert, but if you give us some more details about how this other application is operating then I'm sure you'll get more help on that.



I am sorry for the confusion. The program that creates the system var is by someone else and i dont have access to see it's working. If that were the case with the system variable created by another program, then i would simple like to stick to the absolute folder path or may be create a system variable myself . The log file was generated only when I gave no path and just the log file name. it was generated in the eclipse folder. But when I deploy it i dont know where it will get created. But when i tried an absolute folder path, the log was not created. Would be great if i can see examples of using absolute folder path and also to create system variable within the program before log generation. Thanks.
 
No, tomorrow we rule the world! With this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!