• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to save logs into .log file

 
Arvind Porlekar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using SLF4J and as per requirement i have to store the logs into the .log file. But when i run the program the log are not written into thelog file.

Here is the code







i want to store the log into the C:\checkLog.log.

does anyone help me to solve this problem.

 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your log4j properties in the CLASSPATH?
 
Arvind Porlekar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Martijn Verburg,

Thanks for your quick response..!!

But how can i put log4j.properties into CLASSPATH..?? As this is not a jar file.

Any suggestion for store the log4j.properties into classpath.?

Thanks ,
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can drop it into any directory that is on your CLASSPATH, so for example in the directory that has your .class files (or your .jar file) or say where your third party libs are (log4j.jar).
 
Arvind Porlekar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added ths log4j.properties into the classpath..

here is the .classpath now..!!




But now if i run the program ..still the debug values are not saved into the C:\checkLog.log file..

does i am missing something.??
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I see you are using Eclipse . You almost had the right idea! You can't actually add the log4.properties file as a library, so you'll want to remove that line to start with.

All you need to do is to put the log4j.properties file into one of your src directories. When Eclipse compiles for you it will make a copy of that file into the target directory, which means it's automatically on the CLASSPATH.
 
Arvind Porlekar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

here is the project structure.


Yes you are right...if i put log4j.properties file into the src directory,the eclipse load that file into CLASSPATH automatically.

But still the debug statement value is not stord into the file (C:\checkLog.log).

For storing that log,does i need to do some extra configuration into the Eclipse.??


Thanks,
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, good stuff! Now you need to look at the Threshold value you have set in your properties file, see how it's set to INFO? That's too high for your debug messages....
 
Arvind Porlekar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is modified log4j.properties.



when i run the program i get following output on console.

In main method i have added following code for showing all values.




I can see following output on console



but i am not able to see debug value on console as well as in log file..!!

 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try DEBUG as opposed to debug in your properties config.
 
Arvind Porlekar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I tried with DEBUG Value. Still debug value is not stored into the file as well as on console

I tried with isDebugEnabled() method which always return false result..

Do i need do some configuration for isDebugEnabled() to set true.???

I am using SLF4J.

Thanks
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show your logger configuration for the console appender? I only se the file one there
 
Arvind Porlekar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
log4j.property file:
I have done some modification with log4j.property file.
here is complete log4j.property file.



 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TRy setting a threshold on your CA appender.
 
Arvind Porlekar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still it is not working..

 
Arvind Porlekar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..

I think this is problem of SLF4J. Because i tried with Log4J I am able to store the log into the log file.

 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not overly familiar with SLF4J, I was pretty much steering you in the direction that Log4J would take (I understand they have similar configuration). Have you tried the how to examples on the slf4j website?
 
Arvind Porlekar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Martijn Verburg

I am able to run the application with storing the log into log files.
I have added 3 jars into CLASSPATH as
1. log4j-1.2.12.jar
2. slf4j-api-1.6.1.jar
3. slf4j-log4j12-1.6.1.jar

Thanks for your quick response.

Regards
Arvind
 
Geeta Puttappanavar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arvind Porlekar wrote:Hi Martijn Verburg

I am able to run the application with storing the log into log files.
I have added 3 jars into CLASSPATH as
1. log4j-1.2.12.jar
2. slf4j-api-1.6.1.jar
3. slf4j-log4j12-1.6.1.jar

Thanks for your quick response.

Regards
Arvind


Hi Martin,

Even I’m facing the same problem. I tried with simple java application, that’s working fine.

But for web application ‘m not at all getting the logs both in log file & console.

If you share your web application log4j example. Really that helps me a lot.

Thanks,
Geeta
 
Panikiran Venkatesh Periyapatna
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even i am facing the same issue. As soon as the application boots up. It reads the properties file and creates the log file. But nothing gets logged into the file.

Any solution found?
 
gopika Nair
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I had the same error and had done all the suggestions in many forums, nothing worked out for me.
Then i went to Apache-Log4j site and found this solution.

I am using Jboss 7.1 AS. In the configuration file - standalone.xml edit the follwoing tag. (stop your server and edit)


The ALL has the lowest possible rank and is intended to turn on all logging.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic