Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Vikas Kumar Gupta
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..?
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vikas Kumar Gupta
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic