• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..?
 
Ranch Hand
Posts: 492
Firefox Browser VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic