Hello group,
I have just been trying out the log4j library. As far as I understand
the idea is to keep the logging statements in your, even in the release
build. However, obviously you wouldn't want to have to ship the log4j
jar with your app, to avoid class definition not found exceptions. As
a matter of fact you wouldn't want the end user to be able to turn on
logging.
I have been thinking about how to handle this. The only thing I can
come up with so far, is just create a couple wrapper classes round the
log4j classes and replace them with empty onces at build-time.
Is this the only way to handle this problem? Has someone out there found
a more elegant way?
Thanks in advance,
regards,
Jan van Mansum. 4 3249
Just as a quick idea, could'nt you check if the log4j Logger class exists on
start up through java reflection?
If it exists you would use the logger and if it does not there will be no
logging done.
Of course you can wrap this functionality in a class that would do the
checks upon start up.
You could also try to catch the ClassNotFound exception where ever you use
log4j and do nothing about it.
Not sure if that helps.
Roman.
"Jan van Mansum" <jv*@nospam.com> wrote in message
news:40*********************@news.xs4all.nl... Hello group,
I have just been trying out the log4j library. As far as I understand the idea is to keep the logging statements in your, even in the release build. However, obviously you wouldn't want to have to ship the log4j jar with your app, to avoid class definition not found exceptions. As a matter of fact you wouldn't want the end user to be able to turn on logging.
I have been thinking about how to handle this. The only thing I can come up with so far, is just create a couple wrapper classes round the log4j classes and replace them with empty onces at build-time.
Is this the only way to handle this problem? Has someone out there found a more elegant way?
Thanks in advance, regards, Jan van Mansum.
Just as a quick idea, could'nt you check if the log4j Logger class exists on
start up through java reflection?
If it exists you would use the logger and if it does not there will be no
logging done.
Of course you can wrap this functionality in a class that would do the
checks upon start up.
You could also try to catch the ClassNotFound exception where ever you use
log4j and do nothing about it.
Not sure if that helps.
Roman.
"Jan van Mansum" <jv*@nospam.com> wrote in message
news:40*********************@news.xs4all.nl... Hello group,
I have just been trying out the log4j library. As far as I understand the idea is to keep the logging statements in your, even in the release build. However, obviously you wouldn't want to have to ship the log4j jar with your app, to avoid class definition not found exceptions. As a matter of fact you wouldn't want the end user to be able to turn on logging.
I have been thinking about how to handle this. The only thing I can come up with so far, is just create a couple wrapper classes round the log4j classes and replace them with empty onces at build-time.
Is this the only way to handle this problem? Has someone out there found a more elegant way?
Thanks in advance, regards, Jan van Mansum.
Roman wrote: Just as a quick idea, could'nt you check if the log4j Logger class exists on start up through java reflection? If it exists you would use the logger and if it does not there will be no logging done. Of course you can wrap this functionality in a class that would do the checks upon start up.
That's an idea, only the "hackers" among our end users could still turn
on logging that way. (It wouldn't do them much good, as the release code
gets obfuscated, but anyway ...) You could also try to catch the ClassNotFound exception where ever you use log4j and do nothing about it.
That helps, but would force me to write try-catch blocks for every
logging statement, which IMHO is not such a good idea.
In short, I think I'll go for the empty class solution. Thanks anyway
for your comments.
Regards,
Jan van Mansum.
Roman wrote: Just as a quick idea, could'nt you check if the log4j Logger class exists on start up through java reflection? If it exists you would use the logger and if it does not there will be no logging done. Of course you can wrap this functionality in a class that would do the checks upon start up.
That's an idea, only the "hackers" among our end users could still turn
on logging that way. (It wouldn't do them much good, as the release code
gets obfuscated, but anyway ...) You could also try to catch the ClassNotFound exception where ever you use log4j and do nothing about it.
That helps, but would force me to write try-catch blocks for every
logging statement, which IMHO is not such a good idea.
In short, I think I'll go for the empty class solution. Thanks anyway
for your comments.
Regards,
Jan van Mansum. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Greg Scharlemann |
last post by:
I have a various different packages within this web application that I
am writing and I am attempting to set up log4j to log directly to a
database. So each class is calling just a generic logger:...
|
by: Ravi Shankar |
last post by:
Hi all,
I have an enterprise application. I am using Apache Log4J for the logging
purposes. WHen a request is received by the application, it goes throug
servlets and many classes, and the...
|
by: Irmen de Jong |
last post by:
Hello
I'm using the logging module in Python 2.3.3, with a format string
containing %(asctime). But it now dumps a full date +timestamp in
the log, which is nice but sometimes I only want the...
|
by: greg.knaddison |
last post by:
Hi,
I'm trying to use the httpclient within Jython (see
http://jakarta.apache.org/commons/httpclient/ for more information on
the httpclient).
My Jython version is:
Jython 2.1 on...
|
by: Joe Bloggs |
last post by:
Hi all,
I take the pleasure to inform that Dotnet Commons Logging has been released
for use.
Dotnet Commons Logging, a subproject of the Donet Commons project currently
located under the...
|
by: Rotem |
last post by:
Hi,
while working on something in my current project I have made several
improvements to the logging package in Python, two of them are worth
mentioning:
1. addition of a logging record field...
|
by: Baurzhan Ismagulov |
last post by:
Hello all,
I want that each module has its own logger. I've defined the following
config file:
keys=f01
keys=console
|
by: sainiranji |
last post by:
Hi All
I have diffrent categories in diffrrent logging purpose and all are working fine...but now my requirment is to disable all at once .
The below are change i did for disable all logges...
|
by: myusernotyours |
last post by:
Hi all,
I have scoured the net for this opinion, and I have come to the conclusion that many think log4j is the superior API. I therefore would like to hear the opinion of you guys here at bytes. ...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |