logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: Log4j2 improvement?
Date Sat, 31 Jan 2015 20:18:14 GMT
You can already do:

ConfigurationSource source = new ConfigurationSource(config.getBytes(“UTF-8”));
Configurator.initialize(this.getClass().getClassLoader(), source);

Or are you suggesting that there should be some string variable that Log4j knows about that
is somehow magically set?

Maybe I’m not understanding what you want to do.

Also, you say that “everything explodes”.  Do you have a stack trace for us to look at?

Ralph




> On Jan 31, 2015, at 9:05 AM, Alvaro de Lucas <alvarolucas@yahoo.es> wrote:
> 
> Hi there, 
> 
> 
> First of all, sorry about my poor english. I hope you'll understand this email... and
this is the right way to do this...
> 
> 
> I would try to explain in 2 minutes to what I think it could be a good improvement for
the amazing log4j2 library...(in case it doesn't already exist...)
> 
> I'm developing a service (based on a J2EE web server and an App) and I've been working
with log4j v2 intensively last days using it in a J2EE project.
> 
> Now I'm trying to upgrade the log4j v1 I used in the app to v2, and I would like to use
a similar log4j2.xml file I used on the web server.
> 
> I've been unable to use log4j2 in the App in the same way I use it in the web server
(probably because its a servlet 3.0 and it uses  Log4jServletContextListener and Log4jServletFilter...).There,
you just need to use LogManager.getLogger ("foo") to load the foo logger described in the
log4j2.xml, and everything is quite easy...
> 
> But as I said, I think I'm not able to load the log4j2.xml on Android environment (and
I put the file in every directory :-)
> ... and when I call LogManager.getLogger ("foo") everything explodes (it raises and exception...)
> 
> I've read the manual, I looked into the API, I searched into all kind of forums, ...
but I've just found a lot of people in the same situation and I think I'm looking for something
that doesn't exist...
> 
> In the situation I describe, I think the typical solution is to configure everything
from scratch programatically... but it will be complex and difficult to do and manage...
> 
> I think the best solution in this case would be to provide the log4j2.xml information
directly into a String... (instead putting the file in a concrete place and wait for the lib
to find it, it would be great to be able to give it directly the content of the file into
a String and use this alternative when there's no way to load the file...
> 
> I've found a lot of people trying to put the file here and there looking for the lib
to find it when it looks easier to send the configuration information direcly into a String
variable...
> 
> Does it have any sense for you?
> Does this already exist? is there a way to do it using what already exists?
> 
> Thank you very much in advance
> Kindest regards
> 
> (Yesterdary I posted about this on StackOverflow here: http://stackoverflow.com/questions/28235021/log4j2-on-android
<http://stackoverflow.com/questions/28235021/log4j2-on-android>)
> 


Mime
View raw message