File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How could I write logs (using java.util.logging) to different file based on differet package? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How could I write logs (using java.util.logging) to different file based on differet package?" Watch "How could I write logs (using java.util.logging) to different file based on differet package?" New topic
Author

How could I write logs (using java.util.logging) to different file based on differet package?

Vikas Kumar Gupta
Greenhorn

Joined: Aug 03, 2011
Posts: 4
Hi,
I am trying to use java.util.logging for writing logs.

My purpose is to write logs to different files based upon different package in my project.

eg I have two packages com.A and com.B
for logs from package com.A I want logs to be written to file D:/logsA/logsA.log and.
for logs from package com.B I want logs to be written to file D:/logsB/logsB.log

Currently I am using only one java.util.logging.FileHandler and that is writing all logs from application to one common log file.

my current configuration property file is like this


Waiting for response,

Regards,
Vikas Kumar Gupta
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Hi and welcome to the JavaRanch.

My question would be: why did you choose java.util.logging and not the generally better considered alternatives such as SLF4J, LogBack, Log4J, etc..?

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

Vikas Kumar Gupta wrote:Hi,
I am trying to use java.util.logging for writing logs.

My purpose is to write logs to different files based upon different package in my project.

eg I have two packages com.A and com.B
for logs from package com.A I want logs to be written to file D:/logsA/logsA.log and.
for logs from package com.B I want logs to be written to file D:/logsB/logsB.log

Currently I am using only one java.util.logging.FileHandler and that is writing all logs from application to one common log file.

my current configuration property file is like this


Waiting for response,

Regards,
Vikas Kumar Gupta


I dont see a question anywhere in your post. You mention what you are trying to do, but not what you are doing. Are there errors? Is something not working right? You have put effort into the question otherwise no one will answer.


Hunter


"If the facts don't fit the theory, get new facts" --Albert Einstein
Vikas Kumar Gupta
Greenhorn

Joined: Aug 03, 2011
Posts: 4
Hi Wouter Oet,
I am forced to use java.util.logging and not other alternative because our project is dependent on some other internal projects that are using java.util.logging.

I know that we can use log4j for what I am trying to accomplish with java.util.logging. Can you please help me in this regard?

Hi Hunter McMillen,
For your reply that you asked me that you don't see a question in my post; I would say that I wanted to know that how could I accomplish my target. What I did is I used a config entry in my logging property file.



and then wrote a ConfigLogger class. That is


but when I am deploying to my WebLogic server, it's giving error as


This is what I tried. Earlier I did not write these thing so that you may suggest me any other method by which I can do this.

Thanks both of you for replying.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How could I write logs (using java.util.logging) to different file based on differet package?
 
Similar Threads
help configuring log4j properties file to mirror java.util.logging (juli) already in place
java.util.Logging configuration...
slf4j logging issue - log file not getting generated
NX: Logging using FileHandler
RAD6/WAS6 Logging config..