This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification 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
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Logging a single java application into 2 logs

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say my application have 2 outcomes, success and failure

If success, it will log into one log, if fail it will log into another

but somehow, when it logs, logging messages will show in both of the logs

The code is shown below:
 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using log4j as the underlying framework?

If so, check the addidivity clause, e.g:


WP
 
cle tan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

William P O'Sullivan wrote:Are you using log4j as the underlying framework?

If so, check the addidivity clause, e.g:


WP



no i am using java.util.logging framework

i have probs configuring with the log4j, first is the log4j.properties, i find it a bit troublesome and confusing

is it possible to implement it with java.util.logging framework?
 
William P O'Sullivan
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your properties file then?

WP
 
cle tan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

William P O'Sullivan wrote:Can you post your properties file then?

WP


not very sure whether my installation was correct for log4j

i just put the log4j.jar inside the java ext lib for jdk and jre

then now there seems to be a log4j alpha ver, without a jar

not sure what's it used for


 
cle tan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

William P O'Sullivan wrote:Can you post your properties file then?

WP



this is my log4j.properties file

not very sure where should i place in eclipse , and where is my output for the logger
 
cle tan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone knows how to solve this problem?

i need more guidance regarding this

i have been going through log4j documentation but can't get it to work as it can't locate the log4j.properties file
 
William P O'Sullivan
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You said you were not using log4j due to problems you had!

I think you're confused. Logging frameworks such as commons and slf4j can be complex but usually
sit on top of a physical logging layer (They are facades). I would write a very simple servlet and test
the logging that your code uses.

Also, what is your application server?

WP
 
Ranch Hand
Posts: 163
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


What's happening here? Should errorLogger and auditLogger be distinct, separate logs?

 
cle tan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

William P O'Sullivan wrote:You said you were not using log4j due to problems you had!

I think you're confused. Logging frameworks such as commons and slf4j can be complex but usually
sit on top of a physical logging layer (They are facades). I would write a very simple servlet and test
the logging that your code uses.

Also, what is your application server?

WP



I am still welcoming any solution that can solve my problem, be it java .util.logging or log4j.

I am using the log4j as i assume there is no easy solution if i use java.util.logging


I am just running a eclipse java application but am having problems with log4j logger

Somehow I put the log4j.properties in the src file and it works, but i can't output the file
src
|---package
|----log4j.properties


may i know whether I can write this code in log4j.properties?
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=C:/logging.log
 
cle tan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bill Clar wrote:

What's happening here? Should errorLogger and auditLogger be distinct, separate logs?



yes, how do i configure them to be distinct and separate logs to log the same java application?

Note that the code above uses java.util.logging
 
cle tan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
implemented separate logging in 2 classes

so that if success logging will be done in another class

 
What kind of corn soldier are you? And don't say "kernel" - that's only for 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!