How do I configure Log4J to send different levels to different appenders

2007-07-04 Thread Mikael Ståldal
I have two appenders, MAIN_LOG and DEBUG_LOG. I have the loggers set up to match Java class 
hierarchy as recommended. I have two interesting codebases, "com.mycompany" and 
"com.othercompany".


I want to send DEBUG and higher from "com.mycompany" and WARN and higher from 
"com.othercompany" to MAIN_LOG. And I want to send DEBUG and higher from "com.mycompany" and 
DEBUG and higher from "com.othercompany" to DEBUG_LOG.


Finally I want to handle stuff outside "com.mycompany" or "com.othercompany" (such as 
"org.thirdparty") by sending ERROR and higher to MAIN_LOG and INFO and higher to DEBUG_LOG.


How do I accomplish that?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How do I configure Log4J to send different levels to different appenders

2007-07-04 Thread Mikael Ståldal

Norbert Toth-Gati wrote:

You may try to configure the following categories:

   
   
   
   
   

   
   
   
   

   
   
   
   


It doesn't work. I end up with an empty MAIN_LOG and the following error 
message:

log4j:ERROR Attempted to append to closed appender named [MAIN_LOG].

You may need to configure all the thirdparty logs to end up in the 
following appenders:


   
   
   
   
   
   
   
   


I would prefer to have a catch-all rule. I guess that the  element can be used for 
that, but you can only have one  element.


Here is the complete log4j.xml I tested with:



http://jakarta.apache.org/log4j/";>

   
  
  
  
  
  
   

   
  
  
  
  
  
   

   
   
   
   
   

   
   
   
   

   
   
   
   




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How do I configure Log4J to send different levels to different appenders

2007-07-04 Thread Mikael Ståldal

Norbert Toth-Gati wrote:

Concerning the :"log4j:ERROR Attempted to append to closed appender named
[MAIN_LOG]." Please follow the link, as a similar problem is discussed:
http://www.mail-archive.com/[EMAIL PROTECTED]/msg01365.html


I have read that thread, and it explains why the solution you proposed doesn't work. But it 
doesn't give me any working solution.



Yep, you cannot use root-element for that.


So what should I use?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How do I configure Log4J to send different levels to different appenders

2007-07-05 Thread Mikael Ståldal

Curt Arnold wrote:
Set root threshold to debug, attach both appenders to root.  Write 
custom filters for your rules and attach the filters to the appenders.


By "custom filter", do you mean writing my own Java class implementing 
org.apache.log4j.spi.Filter?


Is it really not possible to configure log4j in the way I want without writing 
Java code?
That's definitly something that needs to be fixed for log4j 1.3.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Different levels to different appenders

2008-02-21 Thread Mikael Ståldal
I have two appenders, MAIN_LOG and DEBUG_LOG. I have the loggers set up to match Java class 
hierarchy as recommended. I have two interesting codebases, "com.mycompany" and 
"com.othercompany".


I want to send DEBUG and higher from "com.mycompany" and WARN and higher from 
"com.othercompany" to MAIN_LOG. And I want to send DEBUG and higher from "com.mycompany" and 
DEBUG and higher from "com.othercompany" to DEBUG_LOG.


Finally I want to handle stuff outside "com.mycompany" or "com.othercompany" (such as 
"org.thirdparty") by sending ERROR and higher to MAIN_LOG and INFO and higher to DEBUG_LOG.


How do I accomplish that?


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Different levels to different appenders

2008-02-25 Thread Mikael Ståldal

Jim Reilly skrev:
I think your main problem here is that you cannot put the same logger name ="xxx"  

>and have that xxx be the same string, to be able to seperate by logging level.

I am aware of that problem. Now I need a solution.

>I think your only way would be to have multiple appenders that each have their 
own
>log file that are by log level.

That's not what I want.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Different levels to different appenders

2008-02-26 Thread Mikael Ståldal

Paul Smith skrev:
If this truly is what you want, 


Are you implying that it would be a bad idea? Why would it be a bad idea?

then set the logger levels for both 
hierarchies to DEBUG, and write yourself a simple custom Filter 
implementation that accepts/denies events based on your logic, and 
attach a separate configured instance of that filter to each of the 
appenders (accepting/denying as the case may be above). 


I have done that, and it seems to work. I'm not sure how it would affect the 
performance though.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Different levels to different appenders

2008-02-27 Thread Mikael Ståldal

Paul Smith skrev:
Why not simply have all the events your interested in together, in 
context, in one log file?  Have one File appender, and tweak the levels 
to emit/silence loggers you care/don't care about?  I'm personally not 
sure of the advantage of seeking information across 2 log files.   No 
Logging event is an island by itself, it's always the context around 
them that makes each one more valuable.  My own personal opinion is to 
only segment events into different files based on services within an 
application, but I still have a main log file where all of them together 
mix, giving one complete context of a running application.


> I guess my real question is your use case for considering to split
> different levels of different loggers to different files.  If you can
> provide some more background as to how this would make your life easier,
> perhaps there are other features we can suggest?

I am developing an application (com.mycompany) which uses a platform/framework developed by 
another company (com.othercompany) which is still not mature. When developing and debugging 
I'm interested in DEBUG logging from my own applicataion, but not from the platform (it 
doesn't make much sense to me, I don't have the source code and I don't want to dig into its 
internal technical details). I am still interested in WARN and ERROR from the platform 
though, they provide valuable context to my own logging. Moreover, the platforms DEBUG 
logging is quite verbose.


However, I need to keep all DEBUG logging from the platform somewhere. If I suspect a bug in 
the platform, I want to be able to send the full log along with my bug report.


More generally, my apporach is useful when an application is composed of several codebases 
with different developers/maintainers and when none of these codebases are mature. Different 
log files are consumed by different developers.


I have done that, and it seems to work. I'm not sure how it would 
affect the performance though.


Filters can be surprisingly fast.  Still, faster without them, hence 
just make them all go to one file.


I'm not so worried about the performance of the actual filter. I'm more worried about that 
my apporach renders isDebugEnabled() etc ineffective.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Different levels to different appenders

2008-03-03 Thread Mikael Ståldal

Mikael Ståldal skrev:
then set the logger levels for both hierarchies to DEBUG, and write 
yourself a simple custom Filter implementation that accepts/denies 
events based on your logic, and attach a separate configured instance 
of that filter to each of the appenders (accepting/denying as the case 
may be above). 


I have done that, and it seems to work. I'm not sure how it would affect 
the performance though.


Here is the filter code I use. I hereby donate this code to the log4j project. I suggest 
that it's included in the org.apache.log4j.varia package.



import org.apache.log4j.Level;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.Filter;

/**
 * Filter to ACCEPT log messages based on Level and Logger 
name prefix.
 *
 * Parameters:
 * 
 * threshold - the Level threshold
 * prefix - the Logger name prefix, use the empty string to match all 
Loggers
 * (including the root Logger).
 * 
 *
 * This filter is NEUTRAL if the Logger name prefix doesn't match, and will 
ACCEPT or
 * DENY based on Level threshold. You can chain several instances of this 
filter.
 *
 * @author Mikael Ståldal
 */
public class LevelAndPrefixFilter extends Filter {

Level threshold;
String prefix;

@Override
public int decide(LoggingEvent event) {
if (!event.getLoggerName().startsWith(prefix)) {
return NEUTRAL;
}

if (event.getLevel().isGreaterOrEqual(threshold)) {
return ACCEPT;
} else {
return DENY;
}
}

public Level getThreshold() {
return threshold;
}

public void setThreshold(Level threshold) {
this.threshold = threshold;
}

public String getPrefix() {
return prefix;
}

public void setPrefix(String prefix) {
this.prefix = prefix;
}

}

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Configure Log4j 2.0 in a Web Application

2014-04-25 Thread Mikael Ståldal
I am using Log4j 2.0 in a Web Application, which is packaged as a .war
file, and deployed in an application server.

I want to bundle a default Log4j configuration within the .war file, but
make it possible to override it in the application server when deploying,
without tampering with the .war file.

Is that possible with Log4j 2.0? I am currently using Jetty 9.x as
application server, but I would like a solution which can be used in
multiple application servers.

-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Log4j 2 appender for Redis?

2014-04-30 Thread Mikael Ståldal
Are there any appender for Redis for Log4j 2?

-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Re: Logstash & Log4J2

2014-05-19 Thread Mikael Ståldal
I have managed to get logstash to work with Log4j 2 by using the "tcp"
input for logstash and json.

Log4j 2:








Logstash:

input {
  tcp {
port => 4560
codec => "json"
  }
}



On Mon, May 19, 2014 at 1:37 PM, Karl Kildén  wrote:

> Hi,
>
> Logstash is highly extensible and they include a plugin called "log4j". It
> works out of the box with log4j, see this guide for some screenshots and
> such
>
> http://blog.yeradis.com/2013/10/logstash-and-apache-log4j-or-how-to.htmlThat
> plugin does use the socket appender.
>
> I have used this for some time and I have been a happy end user not really
> getting into technical details at all. But for new projects I want to use
> log4j2 and thus my question... Some efforts to get support in for log4j2
> seems to exist already so I guess I will turn my attention to that.
>
> However it felt best to consult the experts of log4j first ;) However I
> guess I will look closer at ie.
> https://github.com/jurmous/logstash-log4j2and other projects for now
> and see if I can get one running ;)
>
>
> On 19 May 2014 13:27, Gary Gregory  wrote:
>
> > So logstash expects serialized Java Log4j 1.2 event objects over a
> socket?
> > That's not going to work with 2.0 out of the box since our implement is
> > different. Can you provide more information to make sure we all
> understand
> > each other please?
> >
> > Gary
> >
> >  Original message From: Karl Kildén <
> > karl.kil...@gmail.com> Date:05/19/2014  02:52  (GMT-05:00)
> > To: Log4J Users List 
> > Subject: Re: Logstash & Log4J2 
> > Hi Gary,
> >
> > Perhaps but if it is not possible it is also the wrong route... It would
> be
> > better to get proper log4j2 support done for logstash. I see some
> > engagement in the area when I google for it, I will try to poke around
> and
> > see if I can help with anything
> >
> > cheers
> >
> >
> > On 18 May 2014 16:12, Gary Gregory  wrote:
> >
> > > Hello,
> > >
> > > If you want the functionality of version 1 in version 2, can you
> create a
> > > patch for a new layout and attach it with tests to a new jira?
> > >
> > > Gary
> > >
> > >  Original message From: Karl Kildén <
> > > karl.kil...@gmail.com> Date:05/16/2014  16:32  (GMT-05:00)
> > > To: Log4J Users List 
> > > Subject: Logstash & Log4J2 
> > > Hello!
> > >
> > > Using the socket appender with log4j1 and logstash simply worked. I
> can't
> > > get it to work with log4j2.
> > >
> > > Any advice on this? Can I make socket appender behave like 1.x?
> > >
> > > cheers
> > >
> >
>



-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Log4j 2.x to GELF

2014-08-05 Thread Mikael Ståldal
Are there any plugins (Appender or Layout) for Log4j 2.x to produce GELF (
http://graylog2.org/gelf)?

I found a few, but only for Log4j 1.x.

-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Re: Log4j 2.x to GELF

2014-08-05 Thread Mikael Ståldal
I have made a GELFLayout, I have attached it to the JIRA issue.


On Tue, Aug 5, 2014 at 2:52 PM, Remko Popma  wrote:

> Oh really? That could be, I confess that I did not search JIRA before
> answering that.
> -Remko
>
>
> On Tue, Aug 5, 2014 at 9:45 PM, Gary Gregory 
> wrote:
>
> > Hm, I thought someone had created a Jira and patch already...
> >
> > Gary
> >
> >  Original message From: Remko Popma <
> > remko.po...@gmail.com> Date:08/05/2014  08:07  (GMT-05:00)
> > To: Log4J Users List 
> > Subject: Re: Log4j 2.x to GELF 
> > There is nothing yet at the moment, but contributions are always
> > welcome!
> >
> > Best regards,
> > Remko
> >
> >
> > On Tue, Aug 5, 2014 at 9:04 PM, Mikael Ståldal <
> > mikael.stal...@appearnetworks.com> wrote:
> >
> > > Are there any plugins (Appender or Layout) for Log4j 2.x to produce
> GELF
> > (
> > > http://graylog2.org/gelf)?
> > >
> > > I found a few, but only for Log4j 1.x.
> > >
> > > --
> > > Mikael Ståldal
> > > Chief Software Architect
> > > *Appear*
> > > Phone: +46 8 545 91 572
> > > Email: mikael.stal...@appearnetworks.com
> > >
> >
>



-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Re: Log4j 2.x to GELF

2014-08-05 Thread Mikael Ståldal
OK, new version attached to JIRA issue, with proper naming. Also added GZIP
compression.


On Tue, Aug 5, 2014 at 5:30 PM, Gary Gregory  wrote:

> Note that we use camel case for names, even for acronyms, so the class
> should be called GelfLayout.
>
> Gary
>
>
> On Tue, Aug 5, 2014 at 11:27 AM, Mikael Ståldal <
> mikael.stal...@appearnetworks.com> wrote:
>
> > I have made a GELFLayout, I have attached it to the JIRA issue.
> >
> >
> > On Tue, Aug 5, 2014 at 2:52 PM, Remko Popma 
> wrote:
> >
> > > Oh really? That could be, I confess that I did not search JIRA before
> > > answering that.
> > > -Remko
> > >
> > >
> > > On Tue, Aug 5, 2014 at 9:45 PM, Gary Gregory 
> > > wrote:
> > >
> > > > Hm, I thought someone had created a Jira and patch already...
> > > >
> > > > Gary
> > > >
> > > >  Original message From: Remko Popma <
> > > > remko.po...@gmail.com> Date:08/05/2014  08:07
>  (GMT-05:00)
> > > > To: Log4J Users List 
> > > > Subject: Re: Log4j 2.x to GELF 
> > > > There is nothing yet at the moment, but contributions are
> always
> > > > welcome!
> > > >
> > > > Best regards,
> > > > Remko
> > > >
> > > >
> > > > On Tue, Aug 5, 2014 at 9:04 PM, Mikael Ståldal <
> > > > mikael.stal...@appearnetworks.com> wrote:
> > > >
> > > > > Are there any plugins (Appender or Layout) for Log4j 2.x to produce
> > > GELF
> > > > (
> > > > > http://graylog2.org/gelf)?
> > > > >
> > > > > I found a few, but only for Log4j 1.x.
> > > > >
> > > > > --
> > > > > Mikael Ståldal
> > > > > Chief Software Architect
> > > > > *Appear*
> > > > > Phone: +46 8 545 91 572
> > > > > Email: mikael.stal...@appearnetworks.com
> > > > >
> > > >
> > >
> >
> >
> >
> > --
> > Mikael Ståldal
> > Chief Software Architect
> > *Appear*
> > Phone: +46 8 545 91 572
> > Email: mikael.stal...@appearnetworks.com
> >
>
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Re: Set the file name based on command line args

2014-08-08 Thread Mikael Ståldal
 > > >>>>>> This electronic mail message contains information that (a)
> is
> >>> or
> >>> > > >>>>>> may be CONFIDENTIAL, PROPRIETARY IN NATURE, OR OTHERWISE
> >>> > > >>>>>> PROTECTED
> >>> > > >>>>>> BY LAW FROM DISCLOSURE, and (b) is intended only for the use
> >>> of
> >>> > > >>>>>> the addressee(s) named herein.  If you are not an intended
> >>> > > >>>>>> recipient, please contact the sender immediately and take
> the
> >>> > > >>>>>> steps necessary to delete the message completely from your
> >>> > > >>>>>> computer system.
> >>> > > >>>>>>
> >>> > > >>>>>> Not Intended as a Substitute for a Writing: Notwithstanding
> >>> the
> >>> > > >>>>>> Uniform Electronic Transaction Act or any other law of
> similar
> >>> > > >>>>>> effect, absent an express statement to the contrary, this
> >>> e-mail
> >>> > > >>>>>> message, its contents, and any attachments hereto are not
> >>> > > >>>>>> intended
> >>> > > >>>>>> to represent an offer or acceptance to enter into a contract
> >>> and
> >>> > > >>>>>> are not otherwise intended to bind this sender,
> >>> > > >>>>>> barnesandnoble.com
> >>> > > >>>>>> llc, barnesandnoble.com inc. or any other person or entity.
> >>> > > >>>>>
> >>> > > >>>>>
> >>> > > >>>>>
> >>> > -
> >>> > > >>>>> To unsubscribe, e-mail:
> >>> log4j-user-unsubscr...@logging.apache.org
> >>> > > >>>>> For additional commands, e-mail:
> >>> > log4j-user-h...@logging.apache.org
> >>> > > >>>>
> >>> > > >>>>
> >>> > > >>>> --
> >>> > > >>>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> >>> > > >>>> Java Persistence with Hibernate, Second Edition
> >>> > > >>>> <http://www.manning.com/bauer3/>
> >>> > > >>>> JUnit in Action, Second Edition <
> >>> http://www.manning.com/tahchiev/>
> >>> > > >>>> Spring Batch in Action <http://www.manning.com/templier/>
> >>> > > >>>> Blog: http://garygregory.wordpress.com
> >>> > > >>>> Home: http://garygregory.com/
> >>> > > >>>> Tweet! http://twitter.com/GaryGregory
> >>> > > >>>
> >>> > > >>>
> >>> > > >>>
> >>> -
> >>> > > >>> To unsubscribe, e-mail:
> >>> log4j-user-unsubscr...@logging.apache.org
> >>> > > >>> For additional commands, e-mail:
> >>> log4j-user-h...@logging.apache.org
> >>> > > >>
> >>> > > >>
> >>> -
> >>> > > >> To unsubscribe, e-mail:
> log4j-user-unsubscr...@logging.apache.org
> >>> > > >> For additional commands, e-mail:
> >>> log4j-user-h...@logging.apache.org
> >>> > > >
> >>> > > >
> >>> > > > --
> >>> > > > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> >>> > > > Java Persistence with Hibernate, Second Edition
> >>> > > > <http://www.manning.com/bauer3/>
> >>> > > > JUnit in Action, Second Edition <
> http://www.manning.com/tahchiev/>
> >>> > > > Spring Batch in Action <http://www.manning.com/templier/>
> >>> > > > Blog: http://garygregory.wordpress.com
> >>> > > > Home: http://garygregory.com/
> >>> > > > Tweet! http://twitter.com/GaryGregory
> >>> > >
> >>> > >
> -
> >>> > > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> >>> > > For additional commands, e-mail:
> log4j-user-h...@logging.apache.org
> >>> > >
> >>> > >
> >>> >
> >>> >
> >>> > --
> >>> > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> >>> > Java Persistence with Hibernate, Second Edition
> >>> > <http://www.manning.com/bauer3/>
> >>> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> >>> > Spring Batch in Action <http://www.manning.com/templier/>
> >>> > Blog: http://garygregory.wordpress.com
> >>> > Home: http://garygregory.com/
> >>> > Tweet! http://twitter.com/GaryGregory
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Matt Sicker 
> >>>
> >>
> >>
> >>
> >> --
> >> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> >> Java Persistence with Hibernate, Second Edition
> >> <http://www.manning.com/bauer3/>
> >> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> >> Spring Batch in Action <http://www.manning.com/templier/>
> >>
> >> Blog: http://garygregory.wordpress.com
> >> Home: http://garygregory.com/
> >> Tweet! http://twitter.com/GaryGregory
> >>
> >
> >
> >
> > --
> > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > Java Persistence with Hibernate, Second Edition
> > <http://www.manning.com/bauer3/>
> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > Spring Batch in Action <http://www.manning.com/templier/>
> > Blog: http://garygregory.wordpress.com
> > Home: http://garygregory.com/
> > Tweet! http://twitter.com/GaryGregory
> >
>
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Log4j 2, ThreadContext and asynchronous servlets

2014-08-20 Thread Mikael Ståldal
Is it possible to have the ThreadContext in Log4j 2 to be request scoped
with asynchronous servlets in a Servlet 3 environment?

With asynchronous servlets, there is no direct connection between request
and thread.

-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Log4j 2.x Web app initialization logging

2014-09-04 Thread Mikael Ståldal
Log4jServletContainerInitializer, Log4jServletContextListener,
Log4jServletFilter and Log4jWebInitializerImpl log some stuff using
ServletContext.log() at startup and shutdown.

Why? I find this logging noisy when done when everything works fine.

-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Re: Log4j 2.x Web app initialization logging

2014-09-04 Thread Mikael Ståldal
I see this line in the source code for version 2.0.2 (line 36):

this.servletContext.log("Log4jServletContextListener ensuring that
Log4j starts up properly.");



On Thu, Sep 4, 2014 at 6:06 PM, Gary Gregory  wrote:

> FWIW, I do not see any logging in Log4jServletContextListener ;-)
>
> G
>
>
> On Thu, Sep 4, 2014 at 12:03 PM, Mikael Ståldal <
> mikael.stal...@appearnetworks.com> wrote:
>
> > Log4jServletContainerInitializer, Log4jServletContextListener,
> > Log4jServletFilter and Log4jWebInitializerImpl log some stuff using
> > ServletContext.log() at startup and shutdown.
> >
> > Why? I find this logging noisy when done when everything works fine.
> >
> > --
> > Mikael Ståldal
> > Chief Software Architect
> > *Appear*
> > Phone: +46 8 545 91 572
> > Email: mikael.stal...@appearnetworks.com
> >
>
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Re: Log4j 2.x Web app initialization logging

2014-09-04 Thread Mikael Ståldal
I think it makes sense to log to ServletContext.log() if something goes
wrong, but not otherwise.

Shouldn't we consider ServletContext.log() as deprecated, and Log4j as the
replacement for it?



On Thu, Sep 4, 2014 at 6:07 PM, Gary Gregory  wrote:

> Should be log only if some condition is met? Like the status logger level
> set to DEBUG?
>
> Gary
>
>
> On Thu, Sep 4, 2014 at 12:03 PM, Mikael Ståldal <
> mikael.stal...@appearnetworks.com> wrote:
>
> > Log4jServletContainerInitializer, Log4jServletContextListener,
> > Log4jServletFilter and Log4jWebInitializerImpl log some stuff using
> > ServletContext.log() at startup and shutdown.
> >
> > Why? I find this logging noisy when done when everything works fine.
> >
> > --
> > Mikael Ståldal
> > Chief Software Architect
> > *Appear*
> > Phone: +46 8 545 91 572
> > Email: mikael.stal...@appearnetworks.com
> >
>
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Re: Log4j 2.x Web app initialization logging

2014-09-05 Thread Mikael Ståldal
Nice.


On Thu, Sep 4, 2014 at 8:32 PM, Matt Sicker  wrote:

> I've fixed this in the master branch.
>
>
> On 4 September 2014 11:24, Mikael Ståldal <
> mikael.stal...@appearnetworks.com
> > wrote:
>
> > I think it makes sense to log to ServletContext.log() if something goes
> > wrong, but not otherwise.
> >
> > Shouldn't we consider ServletContext.log() as deprecated, and Log4j as
> the
> > replacement for it?
> >
> >
> >
> > On Thu, Sep 4, 2014 at 6:07 PM, Gary Gregory 
> > wrote:
> >
> > > Should be log only if some condition is met? Like the status logger
> level
> > > set to DEBUG?
> > >
> > > Gary
> > >
> > >
> > > On Thu, Sep 4, 2014 at 12:03 PM, Mikael Ståldal <
> > > mikael.stal...@appearnetworks.com> wrote:
> > >
> > > > Log4jServletContainerInitializer, Log4jServletContextListener,
> > > > Log4jServletFilter and Log4jWebInitializerImpl log some stuff using
> > > > ServletContext.log() at startup and shutdown.
> > > >
> > > > Why? I find this logging noisy when done when everything works fine.
> > > >
> > > > --
> > > > Mikael Ståldal
> > > > Chief Software Architect
> > > > *Appear*
> > > > Phone: +46 8 545 91 572
> > > > Email: mikael.stal...@appearnetworks.com
> > > >
> > >
> > >
> > >
> > > --
> > > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > > Java Persistence with Hibernate, Second Edition
> > > <http://www.manning.com/bauer3/>
> > > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > > Spring Batch in Action <http://www.manning.com/templier/>
> > > Blog: http://garygregory.wordpress.com
> > > Home: http://garygregory.com/
> > > Tweet! http://twitter.com/GaryGregory
> > >
> >
> >
> >
> > --
> > Mikael Ståldal
> > Chief Software Architect
> > *Appear*
> > Phone: +46 8 545 91 572
> > Email: mikael.stal...@appearnetworks.com
> >
>
>
>
> --
> Matt Sicker 
>



-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Re: [survey] What version of Java do you use?

2014-09-10 Thread Mikael Ståldal
Log4j 2 and Java 7. Will probably start using Java 8 for some projects soon.

On Tue, Sep 9, 2014 at 4:14 AM, Oswaldo Caballero  wrote:

> Hi,
>
> New projects => java 7 and Log4j2
>
> Old projects (maintenance) => java 6 and Log4j1
>
> Best regards,
>
> Oswaldo
>
>
> On Sep 8, 2014, at 6:53 PM, Remko Popma  wrote:
>
> > Currently a mixture of 6 and 7 at work. Slowly moving to a mixture of 7
> and 8, but there's no timeline for that.
> >
> > Sent from my iPhone
> >
> >> On 2014/09/08, at 21:46, Gary Gregory  wrote:
> >>
> >> Curious:
> >>
> >> What version of Java do you use with Log4j 1?
> >> What version of Java do you use with Log4j 2?
> >>
> >> Thank you,
> >> Gary
> >>
> >> --
> >> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> >> Java Persistence with Hibernate, Second Edition
> >> <http://www.manning.com/bauer3/>
> >> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> >> Spring Batch in Action <http://www.manning.com/templier/>
> >> Blog: http://garygregory.wordpress.com
> >> Home: http://garygregory.com/
> >> Tweet! http://twitter.com/GaryGregory
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Re: [ANNOUNCEMENT] Apache Log4j 2.1 released

2014-10-28 Thread Mikael Ståldal
> started by Tomcat after web application stop. Thanks to Gary
> Gregory.
> o LOG4J2-391:  FlumePersistentManager now handles LockConflictExceptions
> in Berkeley Db when sending a batch. Thanks to Kamal Bahadur.
> o LOG4J2-782:  Remove invalid Oracle Maven repository.
> o LOG4J2-796:  Fixed issue where log4j-to-slf4j did not work correctly
> with SLF4J Simple Logger.
> o LOG4J2-811:  SimpleLogger throws ArrayIndexOutOfBoundsException for an
> empty array. Thanks to Yogesh Rao.
> o LOG4J2-663:  Fix OSGi Import-Package problem with the JMS API. Thanks to
> Florian Brunner.
> o LOG4J2-783:  PatternLayout should use platform character encoding by
> default, not UTF-8. Thanks to Minglei Lee.
>
> Changes:
> o LOG4J2-845:  Add 2.1.0 to compatible versions in Log4j API ProviderUtil
> and update Log4jAPIVersion to 2.1.0 in
> core META-INF/log4j-provider.properties.
> o LOG4J2-844:  Update JMH to 1.1 from 0.7.2.
> o LOG4J2-831:  Documentation: updated FAQ "which jars" diagrams for JUL
> bridge and 2.1 version.
> o LOG4J2-780:  Update Spring Framework to 3.2.11.RELEASE from
> 3.2.8.RELEASE.
> o LOG4J2-815:  Unify the two JMS appenders into a single appender.
> Configurations written for 2.0 will still work in 2.1+.
> o LOG4J2-790:  Update Jackson to 2.4.2 from 2.4.1 (for XML and JSON
> processing).
> o LOG4J2-766:  Incomplete documentation for JSONLayout. Thanks to Bruno P.
> Kinoshita.
> o LOG4J2-800:  All life cycle implementations should be serializable.
> This is still work in progress.
> o LOG4J2-801:  org.apache.logging.log4j.core.Logger should be serializable.
> This is still work in progress.
> o LOG4J2-810:  Update javax.mail to 1.5.2 from 1.5.0.
> o LOG4J2-822:  Update org.eclipse.persistence.jpa to 2.5.2 from 2.5.1.
> o LOG4J2-867:  FlumeAppender: maxDelay not in seconds, but milliseconds.
> Add time scale to some settings, for example maxDelayMillis
> instead of maxDelay.
> The old names are aliased for compatibility.
>
>
> Apache Log4j 2.1 requires a minimum of Java 6 to build and run. Basic
> compatibility with
> Log4j 1.x is provided through the log4j-1.2-api component, however it does
> not implement some of the
> very implementation specific classes and methods. The package names and
> Maven groupId have been changed to
> org.apache.logging.log4j to avoid any conflicts with log4j 1.x.
>
> For complete information on Apache Log4j 2, including instructions on how
> to submit bug reports,
> patches, or suggestions for improvement, see the Apache Apache Log4j 2
> website:
>
> http://logging.apache.org/log4j/2.x/
>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.stal...@appearnetworks.com


Strage warning about MessageFactory mismatch

2015-03-23 Thread Mikael Ståldal
I get the following strange warning from Log4j 2.2:

WARN The Logger MyLogger was created with the message factory
org.apache.logging.log4j.message.MessageFormatMessageFactory@516986e6 and
is now requested with a null message factory (defaults to
org.apache.logging.log4j.message.ParameterizedMessageFactory), which may
create log events with unexpected formatting.

I have these libraries in my classpath:
log4j-1.2-api-2.2.jar
log4j-api-2.2.jar
log4j-core-2.2.jar
log4j-jul-2.2.jar
log4j-slf4j-impl-2.2.jar
slf4j-api-1.7.7.jar

Why do I get this warning? The logging seems to work properly.

-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Log4j 2 plugin in Scala

2015-04-07 Thread Mikael Ståldal
Is it possible to write a Log4j 2 plugin in Scala?

Using Log4j 2.2.

-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: adding log4j 2.x support to a library

2015-04-30 Thread Mikael Ståldal
Please don't make the library depend on log4j-core. A library should only
depend on log4j-api and leave log configuration to the application using
the library.

And don't log too much from the library, there are too many libraries out
there doing excessive logging.

On Wed, Apr 29, 2015 at 10:54 PM, Gary Gregory 
wrote:

> You can replace the log4j 1 jar with the log4j 2 compatiblity API. You'll
> also need the log4j 2 API and Core modules.
>
> Please see https://logging.apache.org/log4j/2.x/manual/migration.html
>
> Gary
>
> On Wed, Apr 29, 2015 at 12:53 PM, Mike Calmus  wrote:
>
> > We have some existing code that is used as a library by other projects.
> > This code uses log4j 1.2. We would like to convert it to use log4j 2.x
> but
> > not remove support for 1.2 so that projects that have not yet migrated
> can
> > still see logging. Any thoughts on how this might be accomplished?
> >
> > Thanks.
> >
>
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Incorrectly defined compressionType parameter to GelfLayout

2015-05-06 Thread Mikael Ståldal
I think there is a bug in GelfLayout.

The compressionType parameter does not work, and I can see why in the
source:

@PluginAttribute(value = "compressionThreshold",
defaultString = "GZIP") final CompressionType compressionType,


The value is wrong here.

-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


ThreadContext vs asynchronous app

2015-05-08 Thread Mikael Ståldal
I have an asynchronous web app (in Scala based on Twitter Finagle, not
using Servlet API).

I use Log4j 2.2 for logging, and I want to tag log messages with some
information about requests (such as client IP address and authenticated
user ID).

In a synchronous Servlet based web app, you can use Log4j's TheradContext
for this, but it doesn't work in Finagle's asynchronous environment since
there is no correlation between threads and requests.

How can I do this?

-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


XMLLayout dependencies

2015-05-11 Thread Mikael Ståldal
Which library dependencies do I need to use the XMLLayout? Is this
documented somewhere?

-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: ThreadContext vs asynchronous app

2015-05-18 Thread Mikael Ståldal
No, not really.

There is some discussion on this JIRA issue, but it does not solve my
problem:
https://issues.apache.org/jira/browse/LOG4J2-1010

And even my suggestion in the JIRA issue is not ideal solution, just a
possible workaround.

What I really want is something which work like ThreadContext, and
implicitly put data into the context map of log messages, but which is not
tied to a JVM Thread.

(I am using Log4j 2.3 now, but that doesn't seem to make any difference for
this.)

On Mon, May 18, 2015 at 7:13 PM, Gary Gregory 
wrote:

> Mikael,
>
> Did you get any help on this?
>
> Gary
>
> On Fri, May 8, 2015 at 1:51 AM, Mikael Ståldal 
> wrote:
>
> > I have an asynchronous web app (in Scala based on Twitter Finagle, not
> > using Servlet API).
> >
> > I use Log4j 2.2 for logging, and I want to tag log messages with some
> > information about requests (such as client IP address and authenticated
> > user ID).
> >
> > In a synchronous Servlet based web app, you can use Log4j's TheradContext
> > for this, but it doesn't work in Finagle's asynchronous environment since
> > there is no correlation between threads and requests.
> >
> > How can I do this?
> >
> > --
> > [image: MagineTV]
> >
> >  *Mikael Ståldal*
> > Senior backend developer
> >
> >  *Magine TV*
> >  mikael.stal...@magine.com
> >  Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
> >
> >  Privileged and/or Confidential Information may be contained in this
> > message. If you are not the addressee indicated in this message
> > (or responsible for delivery of the message to such a person), you may
> not
> > copy or deliver this message to anyone. In such case,
> > you should destroy this message and kindly notify the sender by reply
> > email.
> >
>
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Translating log levels

2015-05-19 Thread Mikael Ståldal
Is it possible to translate log levels in the configuration.

I have some 3rd party libraries who log stuff on too high level, so I would
need a way to say that logging from "com.somecompany.funlibrary" on level
ERROR should be translated to WARN.

-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Translating log levels

2015-05-20 Thread Mikael Ståldal
It seems like I would have to implement a custom RewitePolicy to accomplish
this, none of the two bundled RewritePolicies can do this.

On Tue, May 19, 2015 at 10:38 PM, Gary Gregory 
wrote:

> Do you need a custom RewritePolicy?
> Gary
>
>  Original message 
> From: Ralph Goers 
> Date: 05/19/2015  10:50  (GMT-08:00)
> To: Log4J Users List 
> Subject: Re: Translating log levels
>
> I am assuming you want the Level in the output to say WARN instead of
> ERROR - otherwise simple filtering at the Logger would get you the output.
>
> You can use the RewriteAppender to modify the Level to what you want.
>
> Ralph
>
> > On May 19, 2015, at 8:10 AM, Mikael Ståldal 
> wrote:
> >
> > Is it possible to translate log levels in the configuration.
> >
> > I have some 3rd party libraries who log stuff on too high level, so I
> would
> > need a way to say that logging from "com.somecompany.funlibrary" on level
> > ERROR should be translated to WARN.
> >
> > --
> > [image: MagineTV]
> >
> > *Mikael Ståldal*
> > Senior backend developer
> >
> > *Magine TV*
> > mikael.stal...@magine.com
> > Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
> >
> > Privileged and/or Confidential Information may be contained in this
> > message. If you are not the addressee indicated in this message
> > (or responsible for delivery of the message to such a person), you may
> not
> > copy or deliver this message to anyone. In such case,
> > you should destroy this message and kindly notify the sender by reply
> > email.
>
>
>
> ---------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Translating log levels

2015-05-20 Thread Mikael Ståldal
I created a JIRA issue for this:
https://issues.apache.org/jira/browse/LOG4J2-1023

On Wed, May 20, 2015 at 10:09 AM, Mikael Ståldal 
wrote:

> It seems like I would have to implement a custom RewitePolicy to
> accomplish this, none of the two bundled RewritePolicies can do this.
>
> On Tue, May 19, 2015 at 10:38 PM, Gary Gregory 
> wrote:
>
>> Do you need a custom RewritePolicy?
>> Gary
>>
>>  Original message 
>> From: Ralph Goers 
>> Date: 05/19/2015  10:50  (GMT-08:00)
>> To: Log4J Users List 
>> Subject: Re: Translating log levels
>>
>> I am assuming you want the Level in the output to say WARN instead of
>> ERROR - otherwise simple filtering at the Logger would get you the output.
>>
>> You can use the RewriteAppender to modify the Level to what you want.
>>
>> Ralph
>>
>> > On May 19, 2015, at 8:10 AM, Mikael Ståldal 
>> wrote:
>> >
>> > Is it possible to translate log levels in the configuration.
>> >
>> > I have some 3rd party libraries who log stuff on too high level, so I
>> would
>> > need a way to say that logging from "com.somecompany.funlibrary" on
>> level
>> > ERROR should be translated to WARN.
>> >
>> > --
>> > [image: MagineTV]
>> >
>> > *Mikael Ståldal*
>> > Senior backend developer
>> >
>> > *Magine TV*
>> > mikael.stal...@magine.com
>> > Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>> >
>> > Privileged and/or Confidential Information may be contained in this
>> > message. If you are not the addressee indicated in this message
>> > (or responsible for delivery of the message to such a person), you may
>> not
>> > copy or deliver this message to anyone. In such case,
>> > you should destroy this message and kindly notify the sender by reply
>> > email.
>>
>>
>>
>> -
>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>>
>>
>
>
> --
> [image: MagineTV]
>
>  *Mikael Ståldal*
> Senior backend developer
>
>  *Magine TV*
>  mikael.stal...@magine.com
>  Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
>
>  Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>



-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: ThreadContext vs asynchronous app

2015-05-21 Thread Mikael Ståldal
A good start would be to implement what I suggest in
https://issues.apache.org/jira/browse/LOG4J2-1010,
add possibility to set the context map in calls to the methods in the
Logger interface.

That would make it possible to implement what I need on top of Log4j 2.

I can't come up with any really convenient way to do it in Java, but in
Scala (which I mostly use) you can use implicit parameters and provide a
wrapper like this:

trait ScalaLogger {

  def info(message: String)(implicit context: ContextMap): Unit

}


On Thu, May 21, 2015 at 6:40 AM, Gary Gregory 
wrote:

> Mikael,
>
> Any thoughts on how to get this to work for you? Feel free to dig into the
> code, we are always looking new for contributors :-)
>
> Gary
>
> On Mon, May 18, 2015 at 10:25 AM, Mikael Ståldal <
> mikael.stal...@magine.com>
> wrote:
>
> > No, not really.
> >
> > There is some discussion on this JIRA issue, but it does not solve my
> > problem:
> > https://issues.apache.org/jira/browse/LOG4J2-1010
> >
> > And even my suggestion in the JIRA issue is not ideal solution, just a
> > possible workaround.
> >
> > What I really want is something which work like ThreadContext, and
> > implicitly put data into the context map of log messages, but which is
> not
> > tied to a JVM Thread.
> >
> > (I am using Log4j 2.3 now, but that doesn't seem to make any difference
> for
> > this.)
> >
> > On Mon, May 18, 2015 at 7:13 PM, Gary Gregory 
> > wrote:
> >
> > > Mikael,
> > >
> > > Did you get any help on this?
> > >
> > > Gary
> > >
> > > On Fri, May 8, 2015 at 1:51 AM, Mikael Ståldal <
> > mikael.stal...@magine.com>
> > > wrote:
> > >
> > > > I have an asynchronous web app (in Scala based on Twitter Finagle,
> not
> > > > using Servlet API).
> > > >
> > > > I use Log4j 2.2 for logging, and I want to tag log messages with some
> > > > information about requests (such as client IP address and
> authenticated
> > > > user ID).
> > > >
> > > > In a synchronous Servlet based web app, you can use Log4j's
> > TheradContext
> > > > for this, but it doesn't work in Finagle's asynchronous environment
> > since
> > > > there is no correlation between threads and requests.
> > > >
> > > > How can I do this?
> > > >
> > > > --
> > > > [image: MagineTV]
> > > >
> > > >  *Mikael Ståldal*
> > > > Senior backend developer
> > > >
> > > >  *Magine TV*
> > > >  mikael.stal...@magine.com
> > > >  Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
> > > >
> > > >  Privileged and/or Confidential Information may be contained in this
> > > > message. If you are not the addressee indicated in this message
> > > > (or responsible for delivery of the message to such a person), you
> may
> > > not
> > > > copy or deliver this message to anyone. In such case,
> > > > you should destroy this message and kindly notify the sender by reply
> > > > email.
> > > >
> > >
> > >
> > >
> > > --
> > > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > > Java Persistence with Hibernate, Second Edition
> > > <http://www.manning.com/bauer3/>
> > > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > > Spring Batch in Action <http://www.manning.com/templier/>
> > > Blog: http://garygregory.wordpress.com
> > > Home: http://garygregory.com/
> > > Tweet! http://twitter.com/GaryGregory
> > >
> >
> >
> >
> > --
> > [image: MagineTV]
> >
> >  *Mikael Ståldal*
> > Senior backend developer
> >
> >  *Magine TV*
> >  mikael.stal...@magine.com
> >  Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
> >
> >  Privileged and/or Confidential Information may be contained in this
> > message. If you are not the addressee indicated in this message
> > (or responsible for delivery of the message to such a person), you may
> not
> > copy or deliver this message to anyone. In such case,
> > you should destroy this message and kindly notify the sender by reply
> > email.
> >
>
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Errors when using XMLLayout

2015-05-21 Thread Mikael Ståldal
When trying to use XMLLayout, I get this error.

Using Log4j 2.3 and these additional runtime dependecies:
"com.fasterxml.jackson.core" % "jackson-core" % "2.5.3"

"com.fasterxml.jackson.dataformat" %  "jackson-dataformat-xml" % "2.5.3"



2015-05-21 19:04:47,283 ERROR
com.fasterxml.jackson.databind.JsonMappingException: Not implemented
(through reference chain:
org.apache.logging.log4j.core.impl.Log4jLogEvent["Message"])
com.fasterxml.jackson.databind.JsonMappingException: Not implemented
(through reference chain:
org.apache.logging.log4j.core.impl.Log4jLogEvent["Message"])
at
com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:210)
at
com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:177)
at
com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:190)
at
com.fasterxml.jackson.dataformat.xml.ser.XmlBeanSerializerBase.serializeFieldsFiltered(XmlBeanSerializerBase.java:295)
at
com.fasterxml.jackson.dataformat.xml.ser.XmlBeanSerializer.serialize(XmlBeanSerializer.java:117)
at
com.fasterxml.jackson.dataformat.xml.ser.XmlSerializerProvider.serializeValue(XmlSerializerProvider.java:92)
at
com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1052)
at
com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:923)
at
org.apache.logging.log4j.core.layout.AbstractJacksonLayout.toSerializable(AbstractJacksonLayout.java:54)
at
org.apache.logging.log4j.core.layout.XmlLayout.toSerializable(XmlLayout.java:189)
at
org.apache.logging.log4j.core.layout.AbstractJacksonLayout.toSerializable(AbstractJacksonLayout.java:27)
at
org.apache.logging.log4j.core.layout.AbstractStringLayout.toByteArray(AbstractStringLayout.java:71)
at
org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.append(AbstractOutputStreamAppender.java:108)
at
org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:99)
at
org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:430)
at
org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:409)
at
org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:412)
at
org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:367)
at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:112)
at
org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:732)
at
org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:700)
at org.apache.logging.slf4j.Log4jLogger.info(Log4jLogger.java:178)


-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Log4j 2 plugin in Scala

2015-05-29 Thread Mikael Ståldal
Yes, Scala support Annotations.

On Fri, May 29, 2015 at 5:01 AM, Ralph Goers 
wrote:

> Does Scala support Annotations?
>
> Ralph
>
> > On May 28, 2015, at 6:12 PM, Gary Gregory 
> wrote:
> >
> > The answer would be the same for any Java code base that allows plugins
> via
> > Class.forName(). This is question is not unique to Log4j as it does not
> > know of anything else but the JRE and third party jars. I imagine the
> Scala
> > code would have to make allowances for being instantiated from a POJO...
> >
> > Gary
> >
> > On Tue, Apr 7, 2015 at 8:38 AM, Mikael Ståldal <
> mikael.stal...@magine.com>
> > wrote:
> >
> >> Is it possible to write a Log4j 2 plugin in Scala?
> >>
> >> Using Log4j 2.2.
> >>
> >> --
> >> [image: MagineTV]
> >>
> >> *Mikael Ståldal*
> >> Senior backend developer
> >>
> >> *Magine TV*
> >> mikael.stal...@magine.com
> >> Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
> >>
> >> Privileged and/or Confidential Information may be contained in this
> >> message. If you are not the addressee indicated in this message
> >> (or responsible for delivery of the message to such a person), you may
> not
> >> copy or deliver this message to anyone. In such case,
> >> you should destroy this message and kindly notify the sender by reply
> >> email.
> >>
> >
> >
> >
> > --
> > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > Java Persistence with Hibernate, Second Edition
> > <http://www.manning.com/bauer3/>
> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > Spring Batch in Action <http://www.manning.com/templier/>
> > Blog: http://garygregory.wordpress.com
> > Home: http://garygregory.com/
> > Tweet! http://twitter.com/GaryGregory
>
>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: HipChat Appender

2015-06-11 Thread Mikael Ståldal
It seems like it reimplements parts of Log4j's PatternLayout.

On Wed, Jun 10, 2015 at 7:04 AM, Gary Gregory 
wrote:

> Fair enough. Eventually, Log4j will be on Java 8 as well, but who knows
> when that will be, Java 7 EOL or not.
>
> Gary
>
> On Tue, Jun 9, 2015 at 9:52 PM, Daniel Widdis  wrote:
>
> > I think this one is best left outside of the official log4j release for
> > now.
> >
> > Its main dependency is Collabsoft's HipChatAPI (
> > https://bitbucket.org/collabsoft/hipchatapi/) which is still in "alpha"
> > development (and signs are it's not being actively developed).  That API
> in
> > turn is using version 1 of the HipChat API, which has now been deprecated
> > with a note that "new development should use version 2".  There is a
> > project using the v2 HipChat API (
> https://github.com/evanwong/hipchat-java),
> > but it has a Java 8 dependency.
> >
> > At some point when I get time I may fork my project and try to implement
> > the new API... or better yet, fork the log4j project itself so a patch
> will
> > be easier.
> >
> > For now, a web search points to my project, a single-classfile Custom
> > Appender implementation that's easy enough to add to any project.
> >
> > Dan
> >
> >
> > On 6/9/15 9:09 PM, Gary Gregory wrote:
> >
> >> Oh, and FWIW, a JIRA and patch attached would be best.
> >>
> >> Gary
> >>
> >> On Tue, Jun 9, 2015 at 9:08 PM, Gary Gregory 
> >> wrote:
> >>
> >>  I guess we have not considered this still.
> >>>
> >>> Thoughts from devs and users?
> >>>
> >>> Gary
> >>>
> >>> On Thu, Mar 12, 2015 at 1:05 AM, Daniel Widdis 
> wrote:
> >>>
> >>>  Works fine with 2.2.
> >>>>
> >>>> On 3/12/15 12:22 AM, Gary Gregory wrote:
> >>>>
> >>>>  Note that 2.2 just came out. You might want to make sure your code
> >>>>> still
> >>>>> works with 2.2 and Git master. I'm not sure if anyone will have
> cycles
> >>>>> to
> >>>>> look at this; I'm OOT for the next 4 days.
> >>>>>
> >>>>> Gary
> >>>>>
> >>>>> On Mon, Oct 20, 2014 at 6:32 AM, Gary Gregory <
> garydgreg...@gmail.com>
> >>>>> wrote:
> >>>>>
> >>>>>   Dan,
> >>>>>
> >>>>>> We are in the middle of releasing Log4j 2.1.
> >>>>>>
> >>>>>> Once that is done, I think we'll be able to focus on new features.
> >>>>>>
> >>>>>> If all goes perfectly well, 2.1 will be out at the end of the week.
> >>>>>>
> >>>>>> Gary
> >>>>>>
> >>>>>> On Sun, Oct 19, 2014 at 3:00 PM, Daniel Widdis 
> >>>>>> wrote:
> >>>>>>
> >>>>>>   I've uploaded my project to github for the log4j2 community's
> >>>>>>
> >>>>>>> use/abuse.
> >>>>>>>
> >>>>>>> https://github.com/dbwiddis/log4j2-hipchat
> >>>>>>>
> >>>>>>> On 10/17/14, 12:18 PM, Daniel Widdis wrote:
> >>>>>>>
> >>>>>>>   Threw something together.  It works.   Needs testing and more
> >>>>>>>
> >>>>>>>> javadocs,
> >>>>>>>> of course...
> >>>>>>>>
> >>>>>>>> What's the best path to contribute?  Just stick it up on a code
> >>>>>>>> repository somewhere?  Anyone want to collaborate?
> >>>>>>>>
> >>>>>>>> Dan
> >>>>>>>>
> >>>>>>>> On 10/17/14, 8:51 AM, Gary Gregory wrote:
> >>>>>>>>
> >>>>>>>>   Patches welcome ;-)
> >>>>>>>>
> >>>>>>>>> Gary
> >>>>>>>>>
> >>>>>>>>
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


FATAL Unable to register shutdown hook because JVM is shutting down.

2015-07-16 Thread Mikael Ståldal
I sometimes get the message:
FATAL Unable to register shutdown hook because JVM is shutting down.

This happens in a short running batch job.

Can it be so that Log4j did not have time to initialize fully before
shutting down? What can be done about it?

Log4j 2.3.

-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: FATAL Unable to register shutdown hook because JVM is shutting down.

2015-07-20 Thread Mikael Ståldal
2015-07-20 11:23:31,741 FATAL Unable to register shutdown hook because JVM
is shutting down. java.lang.IllegalStateException: Cannot add new shutdown
hook as this is not started. Current state: STOPPED
at
org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.addShutdownCallback(DefaultShutdownCallbackRegistry.java:113)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.addShutdownCallback(Log4jContextFactory.java:244)
at
org.apache.logging.log4j.core.LoggerContext.setUpShutdownHook(LoggerContext.java:182)
at
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:143)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:146)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
at
org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:102)
at
org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
at
org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:284)
at org.apache.spark.Logging$class.log(Logging.scala:52)
at
org.apache.spark.rpc.akka.AkkaRpcEnv$$anonfun$actorRef$lzycompute$1$1$$anon$1.log(AkkaRpcEnv.scala:93)
at
org.apache.spark.util.ActorLogReceive$$anon$1.apply(ActorLogReceive.scala:55)
at
org.apache.spark.util.ActorLogReceive$$anon$1.apply(ActorLogReceive.scala:42)
at
scala.PartialFunction$class.applyOrElse(PartialFunction.scala:123)
at
org.apache.spark.util.ActorLogReceive$$anon$1.applyOrElse(ActorLogReceive.scala:42)
at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
at
org.apache.spark.rpc.akka.AkkaRpcEnv$$anonfun$actorRef$lzycompute$1$1$$anon$1.aroundReceive(AkkaRpcEnv.scala:93)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at
akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
at
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)


On Sat, Jul 18, 2015 at 1:44 AM, Gary Gregory 
wrote:

> Hi Mikael,
>
> I just committed a minor tweak in git master: Include exceptions when
> logging FATAL events in
> org.apache.logging.log4j.core.LoggerContext.setUpShutdownHook()
>
> Can you try git master and see what is the exception that gets logged?
>
> Thank you,
> Gary
>
> On Thu, Jul 16, 2015 at 1:49 AM, Mikael Ståldal  >
> wrote:
>
> > I sometimes get the message:
> > FATAL Unable to register shutdown hook because JVM is shutting down.
> >
> > This happens in a short running batch job.
> >
> > Can it be so that Log4j did not have time to initialize fully before
> > shutting down? What can be done about it?
> >
> > Log4j 2.3.
> >
> > --
> > [image: MagineTV]
> >
> >  *Mikael Ståldal*
> > Senior backend developer
> >
> >  *Magine TV*
> >  mikael.stal...@magine.com
> >  Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
> >
> >  Privileged and/or Confidential Information may be contained in this
> > message. If you are not the addressee indicated in this message
> > (or responsible for delivery of the message to such a person), you may
> not
> > copy or deliver this message to anyone. In such case,
> > you should destroy this message and kindly notify the sender by reply
> > email.
> >
>
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be cont

Re: FATAL Unable to register shutdown hook because JVM is shutting down.

2015-07-21 Thread Mikael Ståldal
The app do some logging at startup as well, and quite some logging in
between. However, it is a short running batch job, and in this case the JVM
only runs for 6 seconds in total.

See below to get some more context about the timing. The first and last log
line are not from Log4j, they are from a bash script used to start the JVM.

I think that this is not only one problem, but two. First that this occurs
in the first place. Second that it is logged at FATAL level.


2015-07-21 10:11:24,022  Before JVM start

2015-07-21 10:11:24,771  INFO com.magine.maglev.Job$: Startup
[... more logging here ...]
2015-07-21 10:11:30,216 FATAL Unable to register shutdown hook because JVM
is shutting down. java.lang.IllegalStateException: Cannot add new shutdown
hook as this is not started. Current state: STOPPED
at
org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.addShutdownCallback(DefaultShutdownCallbackRegistry.java:113)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.addShutdownCallback(Log4jContextFactory.java:244)
at
org.apache.logging.log4j.core.LoggerContext.setUpShutdownHook(LoggerContext.java:182)
at
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:143)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:146)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
at
org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:102)
at
org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
at
org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:284)
at org.apache.spark.Logging$class.log(Logging.scala:52)
at
org.apache.spark.rpc.akka.AkkaRpcEnv$$anonfun$actorRef$lzycompute$1$1$$anon$1.log(AkkaRpcEnv.scala:93)
at
org.apache.spark.util.ActorLogReceive$$anon$1.apply(ActorLogReceive.scala:55)
at
org.apache.spark.util.ActorLogReceive$$anon$1.apply(ActorLogReceive.scala:42)
at
scala.PartialFunction$class.applyOrElse(PartialFunction.scala:123)
at
org.apache.spark.util.ActorLogReceive$$anon$1.applyOrElse(ActorLogReceive.scala:42)
at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
at
org.apache.spark.rpc.akka.AkkaRpcEnv$$anonfun$actorRef$lzycompute$1$1$$anon$1.aroundReceive(AkkaRpcEnv.scala:93)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at
akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
at
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

2015-07-21 10:11:30,558 After JVM end


On Tue, Jul 21, 2015 at 12:58 AM, Remko Popma  wrote:

> Gary, enjoy your holiday!
>
> Mikael,
> At first glance it seems to me that this problem happens because the
> application does not start logging until it has done all the work and the
> JVM is shutting down.
>
> However, I'm not sure it really is a problem: Log4j tried to registered a
> shutdown hook, but couldn't. It then notified you of the problem and
> continued to work. (The stack trace was generated from a try/catch block.)
>
> If this error report is annoying, a workaround may be to change to your app
> to start logging at startup.
>
> Remko
>
> On Mon, Jul 20, 2015 at 6:25 PM, Mikael Ståldal  >
> wrote:
>
> > 2015-07-20 11:23:31,741 FATAL Unable to register shutdown hook because
> JVM
> > is shutting down. java.lang.IllegalStateException: Cannot add new
> shutdown
> > hook as this is not started. Current state: STOPPED
> > at
> >
> >
> org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.addShutdownCallback(DefaultShutdownCallbackRegistry.java:113)
> > at
> >
> >
> org.apache.logging.log4j.core.impl.Log4jContextFactory.addShutdownCallback(Log4jContextFactory.java:244)
> > at
> >
> >
> org.apache.logging.log4j.core.LoggerContext.setUpShutdownHook(LoggerContext.java:182)
> > at
> > org.apache.logging.log4j.core.LoggerCont

Re: FATAL Unable to register shutdown hook because JVM is shutting down.

2015-07-21 Thread Mikael Ståldal
There is only one JVM process involved as far as I know. I have a script
which looks like this:

#!/bin/sh
date "+%F %T,%N Before JVM start"
java
com.magine.maglev.Job
-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager
date "+%F %T,%N After JVM end"


I tried to make it run longer by a Thread.sleep(60*1000), but same problem:

2015-07-21 15:51:04,599538113 Before JVM start
2015-07-21 15:51:05,366  INFO com.magine.maglev.Job$: Startup
[... more logging ...]
2015-07-21 15:52:10,799 FATAL Unable to register shutdown hook because JVM
is shutting down. java.lang.IllegalStateException: Cannot add new shutdown
hook as this is not started. Current state: STOPPED
at
org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.addShutdownCallback(DefaultShutdownCallbackRegistry.java:113)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.addShutdownCallback(Log4jContextFactory.java:244)
at
org.apache.logging.log4j.core.LoggerContext.setUpShutdownHook(LoggerContext.java:182)
at
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:143)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:146)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
at
org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:102)
at
org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
at
org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:284)
at org.apache.spark.Logging$class.log(Logging.scala:52)
at
org.apache.spark.rpc.akka.AkkaRpcEnv$$anonfun$actorRef$lzycompute$1$1$$anon$1.log(AkkaRpcEnv.scala:93)
at
org.apache.spark.util.ActorLogReceive$$anon$1.apply(ActorLogReceive.scala:55)
at
org.apache.spark.util.ActorLogReceive$$anon$1.apply(ActorLogReceive.scala:42)
at
scala.PartialFunction$class.applyOrElse(PartialFunction.scala:123)
at
org.apache.spark.util.ActorLogReceive$$anon$1.applyOrElse(ActorLogReceive.scala:42)
at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
at
org.apache.spark.rpc.akka.AkkaRpcEnv$$anonfun$actorRef$lzycompute$1$1$$anon$1.aroundReceive(AkkaRpcEnv.scala:93)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at
akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
at
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

2015-07-21 15:52:11,145821352 After JVM end



On Tue, Jul 21, 2015 at 3:18 PM, Remko Popma  wrote:

> That's strange: if you are logging at startup the shutdown hook should be
> registered before the call to logger.log() returns... Does the batch start
> another JVM process?
>
> Sent from my iPhone
>
> > On 2015/07/21, at 17:18, Mikael Ståldal 
> wrote:
> >
> > The app do some logging at startup as well, and quite some logging in
> > between. However, it is a short running batch job, and in this case the
> JVM
> > only runs for 6 seconds in total.
> >
> > See below to get some more context about the timing. The first and last
> log
> > line are not from Log4j, they are from a bash script used to start the
> JVM.
> >
> > I think that this is not only one problem, but two. First that this
> occurs
> > in the first place. Second that it is logged at FATAL level.
> >
> >
> > 2015-07-21 10:11:24,022  Before JVM start
> >
> > 2015-07-21 10:11:24,771  INFO com.magine.maglev.Job$: Startup
> > [... more logging here ...]
> > 2015-07-21 10:11:30,216 FATAL Unable to register shutdown hook because
> JVM
> > is shutting down. java.lang.IllegalStateException: Cannot add new
> shutdown
> > hook as this is not started. Current state: STOPPED
> >at
> >
> org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.addShutdownCallback(DefaultShutdownCallbackRegistry.java:113)
> >at
> >
> org.apache.logging.log4j.core.impl.Log4jContextFactory.addShutdo

Re: FATAL Unable to register shutdown hook because JVM is shutting down.

2015-07-22 Thread Mikael Ståldal
Yes, Spark seems to have its own shutdown hook and it logs stuff from
within there.

If I put shutdownHook="disable" in my log4j2.xml, the problem goes away.
But then I guess that Log4j is never shut down properly?

On Wed, Jul 22, 2015 at 8:39 AM, Ralph Goers 
wrote:

> The currentContext value indicates whether the LoggerContext stored in the
> ThreadLocal should be used. This is usually the wrong choice which is why
> the value is usually set to false.  Instead, the LoggerContext is located
> via the ClassLoaderContextSelector which finds the LoggerContext for the
> ClassLoader of the class that owns the Logger.
>
> It looks to me like something is trying to log after logging has already
> shut down.  This is causing it to retrieve the LoggerContext, which has
> already been stopped, and then it tries to restart it. Because the
> LoggerContext is normally stopped by the execution of the shutdown hook it
> is a very bad sign that the shutdown hook is trying to be reestablished.
> My guess is that Spark has its own shutdown hook and is trying to log from
> it after our shutdown hook has already run.
>
> When Matt wrote this code I believe he allowed for this situation but I’d
> really have to dig into the code more to figure out. However, I did find
> http://stackoverflow.com/questions/17400136/how-to-log-within-shutdown-hooks-with-log4j2
> <
> http://stackoverflow.com/questions/17400136/how-to-log-within-shutdown-hooks-with-log4j2>
> which says to implement your own ShutdownCallbackRegistry.
>
> It might be a good idea to add the variation of the Shutdown registry
> mentioned in the article so that it can be configured.
>
> Ralph
>
> > On Jul 21, 2015, at 8:57 PM, Remko Popma  wrote:
> >
> > Looks like the context returned by
> > AbstractLoggerAdapter.java:102
> > is the result of LogManager.getContext(someClass, false);
> >
> > The boolean "false" indicates that a different LoggerContext may be
> created (and started). I suspect this is what causes the problem.
> >
> > Ralph understands this part better than me. Ralph, should the slf4j
> Log4jLoggerFactory pass "false" here? The default for LogManager seems to
> be "true"...
> >
> > Remko
> >
> > Sent from my iPhone
> >
> >> On 2015/07/21, at 22:58, Mikael Ståldal 
> wrote:
> >>
> >> AbstractLoggerAdapter.java:102
> >
> > -----
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
>
>


-- 
[image: MagineTV]

 *Mikael Ståldal*
Senior backend developer

 *Magine TV*
 mikael.stal...@magine.com
 Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

 Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: FATAL Unable to register shutdown hook because JVM is shutting down.

2015-08-03 Thread Mikael Ståldal
This is not a web application.

On Thu, Jul 16, 2015 at 11:10 AM, Adam Retter 
wrote:

> Are you using log4j in a web application? If so if you google around
> you can find several suggestions for solving this behaviour.
>
> On 16 July 2015 at 09:49, Mikael Ståldal 
> wrote:
> > I sometimes get the message:
> > FATAL Unable to register shutdown hook because JVM is shutting down.
> >
> > This happens in a short running batch job.
> >
> > Can it be so that Log4j did not have time to initialize fully before
> > shutting down? What can be done about it?
> >
> > Log4j 2.3.
> >
> > --
> > [image: MagineTV]
> >
> >  *Mikael Ståldal*
> > Senior backend developer
> >
> >  *Magine TV*
> >  mikael.stal...@magine.com
> >  Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com
> >
> >  Privileged and/or Confidential Information may be contained in this
> > message. If you are not the addressee indicated in this message
> > (or responsible for delivery of the message to such a person), you may
> not
> > copy or deliver this message to anyone. In such case,
> > you should destroy this message and kindly notify the sender by reply
> > email.
>
>
>
> --
> Adam Retter
>
> skype: adam.retter
> tweet: adamretter
> http://www.adamretter.org.uk
>
> ---------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior backend developer

*Magine TV*
mikael.stal...@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: my results thus far

2015-08-12 Thread Mikael Ståldal
 (My library parses ANSI
> tokens).
> >>>
> >>> Anyway to cut it short now, here is a screenshot of what I've been
> doing:
> >>>
> >>> http://www.xen.dds.nl/f/i/screenshots/thunderbolt-log4j-reward.png
> >>>
> >>> The first field is the thread in blue, there are three threads (thread
> >>> types): main, server and client. Every client thread gets numbered
> from a
> >>> pool that gets refilled when a thread exits (just a Set I take numbers
> out
> >>> of and I always take the first one (SortedSet/TreeSet)). After that is
> the
> >>> logger name. I don't name my loggers anymore by class but by subsystem.
> >>> Essentially, by package, I guess. There are only two packages /
> subsystems
> >>> at the moment that are being shown a third is called "telnet.file" and
> I
> >>> haven't tested it yet.
> >>>
> >>> It's just that my FileAppender doesn't yet work. However since it
> >>> "additives" from "telnet" it also outputs to the console:
> >>>
> >>>
> http://www.xen.dds.nl/f/i/screenshots/thunderbolt-log4j-reward2.smaller.png
> >>>
> >>> Fixed.
> >>>
> >>> So I have 3 loggerconfigs now:
> >>> - "server" --> outputs to root logger
> >>> - "telnet" --> outputs to root logger
> >>> - "telnet.file" --> additionally outputs to a log file.
> >>>
> >>> Regards, and enjoy :p.
> >>>
> >>> Bart.
> >>>
> >>>
> >>>
> >>> -
> >>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> >>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior backend developer

*Magine TV*
mikael.stal...@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: java.lang.NoSuchFieldError: errorHandler

2015-08-14 Thread Mikael Ståldal
Perhaps the Log4j developers should spend some time to persuade other
Apache projects to start using Log4j 2.

On Fri, Aug 14, 2015 at 8:05 AM, Jinhong Lu  wrote:

> you mean upgrade to log4j2?
>
> but all my projects, including spark, hadoop, kafka, they all use log4j1.x
>
> 2015-08-14 13:25 GMT+08:00 Ralph Goers :
>
> > Please see -
> >
> https://blogs.apache.org/foundation/entry/apache_logging_services_project_announces
> > <
> >
> https://blogs.apache.org/foundation/entry/apache_logging_services_project_announces
> > >.
> >
> > Ralph
> >
> > > On Aug 13, 2015, at 10:08 PM, Jinhong Lu  wrote:
> > >
> > > I met this exception when using syslogappender.
> > >
> > > my log4j version is 1.2.16.
> > >
> > > Any idea?  thanks.
> > >
> > >
> > >
> > >
> > > java.lang.NoSuchFieldError: errorHandler
> > >   at
> >
> org.apache.log4j.net.SyslogAppender.setSyslogHost(SyslogAppender.java:391)
> > > ~[log4j-1.2.16.jar:na]
> > >   at
> > com.netease.sytopology.util.MySysLogger.(MySysLogger.java:39)
> > > ~[stormjar.jar:na]
> > >   at
> > com.netease.sytopology.util.MySysLogger.getInstance(MySysLogger.java:28)
> > > ~[stormjar.jar:na]
> > >   at
> >
> com.netease.sytopology.bolt.FilterFunction.prepare(FilterFunction.java:65)
> > > ~[stormjar.jar:na]
> > >   at
> >
> storm.trident.planner.processor.EachProcessor.prepare(EachProcessor.java:54)
> > > ~[storm-core-0.9.4.jar:0.9.4]
> > >   at
> > storm.trident.planner.SubtopologyBolt.prepare(SubtopologyBolt.java:121)
> > > ~[storm-core-0.9.4.jar:0.9.4]
> > >   at
> >
> storm.trident.topology.TridentBoltExecutor.prepare(TridentBoltExecutor.java:231)
> > > ~[storm-core-0.9.4.jar:0.9.4]
> > >   at
> > backtype.storm.daemon.executor$fn__4722$fn__4734.invoke(executor.clj:692)
> > > ~[storm-core-0.9.4.jar:0.9.4]
> > >   at backtype.storm.util$async_loop$fn__458.invoke(util.clj:461)
> > > ~[storm-core-0.9.4.jar:0.9.4]
> > >   at clojure.lang.AFn.run(AFn.java:24) [clojure-1.5.1.jar:na]
> > >   at java.lang.Thread.run(Thread.java:745) [na:1.7.0_67]
> > >
> > >
> > > And here is my code:
> > >
> > >
> > > import org.apache.log4j.Level;
> > >
> > > import org.apache.log4j.Logger;
> > >
> > > import org.apache.log4j.PatternLayout;
> > >
> > > import org.apache.log4j.helpers.OnlyOnceErrorHandler;
> > >
> > > import org.apache.log4j.net.SyslogAppender;
> > >
> > > import org.apache.log4j.varia.FallbackErrorHandler;
> > >
> > >
> > > public class MySysLogger {
> > >
> > > //以下参数均可根据需要放到配置文件中。
> > >
> > > //默认日志级别
> > >
> > > private static Level level = Level.INFO;
> > >
> > > //日志接收服务器
> > >
> > > private static String syslogHost = "172.16.1.18";
> > >
> > > //设置facility
> > >
> > > private static String facility = "local7";
> > >
> > > private static String  loggerName = "";
> > >
> > >
> > > public static void setLoggerName(String loggerName2) {
> > >
> > > MySysLogger.loggerName = loggerName2;
> > >
> > > }
> > >
> > >
> > > private static Logger LOG = null;
> > >
> > >
> > > public static synchronized Logger getInstance() {
> > >
> > > if (LOG == null) {
> > >
> > > new MySysLogger(loggerName);
> > >
> > > }
> > >
> > > return LOG;
> > >
> > > }
> > >
> > >
> > > private  MySysLogger(String loggerName) {
> > >
> > >
> > > LOG = Logger.getRootLogger();
> > >
> > > LOG.setLevel(level);
> > >
> > > SyslogAppender appender = new SyslogAppender();
> > >
> > > appender.setErrorHandler(new FallbackErrorHandler());
> > >
> > >
> > > appender.setSyslogHost(syslogHost);
> > >
> > > appender.setLayout(new PatternLayout(
> > >
> > > "%r " + loggerName +" [%t] %-5p %C%x - %m"));
> > >
> > > appender.setHeader(true);
> > >
> > > appender.setFacility(facility);
> > >
> > > LOG.addAppender(appender);
> > >
> > > }
> > >
> > >
> > > }
> >
> >
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior backend developer

*Magine TV*
mikael.stal...@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: java.lang.NoSuchFieldError: errorHandler

2015-08-14 Thread Mikael Ståldal
I don't agree with you that Log4j 2 is worse than Log4j 1. Log4j 2 is a
huge improvement.

On Fri, Aug 14, 2015 at 4:05 PM, Xen  wrote:

> That is precisely the sort of stuff you get when your application or newer
> version is actually worse than your older version, and now you need to do
> effort to "persuade" others in joining you when you have not really
> improved things ;-).
>
> I was writing some longer email I guess, I will send it later, I guess.
>
> Bye.
>
> Op 14-8-2015 om 10:27 schreef Mikael Ståldal:
>
> Perhaps the Log4j developers should spend some time to persuade other
>> Apache projects to start using Log4j 2.
>>
>> On Fri, Aug 14, 2015 at 8:05 AM, Jinhong Lu  wrote:
>>
>> you mean upgrade to log4j2?
>>>
>>> but all my projects, including spark, hadoop, kafka, they all use
>>> log4j1.x
>>>
>>> 2015-08-14 13:25 GMT+08:00 Ralph Goers :
>>>
>>> Please see -
>>>>
>>>>
>>> https://blogs.apache.org/foundation/entry/apache_logging_services_project_announces
>>>
>>>> <
>>>>
>>>>
>>> https://blogs.apache.org/foundation/entry/apache_logging_services_project_announces
>>>
>>>> .
>>>>>
>>>> Ralph
>>>>
>>>> On Aug 13, 2015, at 10:08 PM, Jinhong Lu  wrote:
>>>>>
>>>>> I met this exception when using syslogappender.
>>>>>
>>>>> my log4j version is 1.2.16.
>>>>>
>>>>> Any idea?  thanks.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> java.lang.NoSuchFieldError: errorHandler
>>>>>at
>>>>>
>>>> org.apache.log4j.net
>>> .SyslogAppender.setSyslogHost(SyslogAppender.java:391)
>>>
>>>> ~[log4j-1.2.16.jar:na]
>>>>>at
>>>>>
>>>> com.netease.sytopology.util.MySysLogger.(MySysLogger.java:39)
>>>>
>>>>> ~[stormjar.jar:na]
>>>>>at
>>>>>
>>>> com.netease.sytopology.util.MySysLogger.getInstance(MySysLogger.java:28)
>>>>
>>>>> ~[stormjar.jar:na]
>>>>>at
>>>>>
>>>>
>>> com.netease.sytopology.bolt.FilterFunction.prepare(FilterFunction.java:65)
>>>
>>>> ~[stormjar.jar:na]
>>>>>at
>>>>>
>>>>
>>> storm.trident.planner.processor.EachProcessor.prepare(EachProcessor.java:54)
>>>
>>>> ~[storm-core-0.9.4.jar:0.9.4]
>>>>>at
>>>>>
>>>> storm.trident.planner.SubtopologyBolt.prepare(SubtopologyBolt.java:121)
>>>>
>>>>> ~[storm-core-0.9.4.jar:0.9.4]
>>>>>at
>>>>>
>>>>
>>> storm.trident.topology.TridentBoltExecutor.prepare(TridentBoltExecutor.java:231)
>>>
>>>> ~[storm-core-0.9.4.jar:0.9.4]
>>>>>at
>>>>>
>>>>
>>>> backtype.storm.daemon.executor$fn__4722$fn__4734.invoke(executor.clj:692)
>>>>
>>>>> ~[storm-core-0.9.4.jar:0.9.4]
>>>>>at backtype.storm.util$async_loop$fn__458.invoke(util.clj:461)
>>>>> ~[storm-core-0.9.4.jar:0.9.4]
>>>>>at clojure.lang.AFn.run(AFn.java:24) [clojure-1.5.1.jar:na]
>>>>>at java.lang.Thread.run(Thread.java:745) [na:1.7.0_67]
>>>>>
>>>>>
>>>>> And here is my code:
>>>>>
>>>>>
>>>>> import org.apache.log4j.Level;
>>>>>
>>>>> import org.apache.log4j.Logger;
>>>>>
>>>>> import org.apache.log4j.PatternLayout;
>>>>>
>>>>> import org.apache.log4j.helpers.OnlyOnceErrorHandler;
>>>>>
>>>>> import org.apache.log4j.net.SyslogAppender;
>>>>>
>>>>> import org.apache.log4j.varia.FallbackErrorHandler;
>>>>>
>>>>>
>>>>> public class MySysLogger {
>>>>>
>>>>> //以下参数均可根据需要放到配置文件中。
>>>>>
>>>>> //默认日志级别
>>>>>
>>>>> private static Level level = Level.INFO;
>>>>>
>>>>> //日志接收服务器
>>>>>
>>>>> private static String syslogHost = "172.16.1.18";
>>>>>
>>>>> //设置facility
>>>>>
>>>>

Re: redefining existing levels?

2015-08-27 Thread Mikael Ståldal
llowed the debug events
> to
> > >>>> flow
> > >>>>>> to
> > >>>>>>>> the log file, correct?
> > >>>>>>>>
> > >>>>>>>> Thanks,
> > >>>>>>>> Nick
> > >>>>>>>>
> > >>>>>>>>> Date: Tue, 25 Aug 2015 12:50:32 -0700
> > >>>>>>>>> Subject: Re: redefining existing levels?
> > >>>>>>>>> From: garydgreg...@gmail.com
> > >>>>>>>>> To: log4j-user@logging.apache.org
> > >>>>>>>>>
> > >>>>>>>>> Nicholas,
> > >>>>>>>>>
> > >>>>>>>>> Yes, please see
> > >>> https://logging.apache.org/log4j/2.x/manual/customloglevels.html
> > >>>>>>>>>
> > >>>>>>>>> If the documentation can be improved, please let us know how.
> > >>>>>>>>>
> > >>>>>>>>> Gary
> > >>>>>>>>>
> > >>>>>>>>> On Tue, Aug 25, 2015 at 12:42 PM, Nicholas Duane <
> > >>> nic...@msn.com
> > >>>>>
> > >>>>>> wrote:
> > >>>>>>>>>
> > >>>>>>>>>> Can existing log4j2 levels be redefined?  I'm able to do this
> > >>>> in
> > >>>>>>>> log4net.
> > >>>>>>>>>> I have yet to see any documentation telling me that I can do
> > >>>> it,
> > >>>>>>>> however,
> > >>>>>>>>>> there was none telling me I could do it for .NET either.  I
> > >>>> just
> > >>>>>>>> happen to
> > >>>>>>>>>> stumble upon a post which eluded to it.  Here is what I've
> > >>>> done in
> > >>>>>> a
> > >>>>>>>>>> log4net config file:
> > >>>>>>>>>>
> > >>>>>>>>>> 
> > >>>>>>>>>>   .
> > >>>>>>>>>>   .
> > >>>>>>>>>>   .
> > >>>>>>>>>>   
> > >>>>>>>>>>  
> > >>>>>>>>>> 
> > >>>>>>>>>> 
> > >>>>>>>>>>  
> > >>>>>>>>>>  
> > >>>>>>>>>> 
> > >>>>>>>>>> 
> > >>>>>>>>>>  
> > >>>>>>>>>>  .
> > >>>>>>>>>>  .
> > >>>>>>>>>>  .
> > >>>>>>>>>>   
> > >>>>>>>>>>   .
> > >>>>>>>>>>   .
> > >>>>>>>>>>   .
> > >>>>>>>>>> 
> > >>>>>>>>>>
> > >>>>>>>>>> As you can see I created my own 'Business' level.  I also
> > >>>> redefined
> > >>>>>>>> Off to
> > >>>>>>>>>> 4 which happens to be the INFO level.  This makes it such
> > >>>> that
> > >>>>>> if
> > >>>>>>>> they
> > >>>>>>>>>> set the level to Off they will still receive INFO and higher
> > >>>> level
> > >>>>>>>> events.
> > >>>>>>>>>>
> > >>>>>>>>>> Can the same thing be done in log4j2?
> > >>>>>>>>>>
> > >>>>>>>>>> Thanks,
> > >>>>>>>>>> Nick
> > >>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>> --
> > >>>>>>>>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > >>>>>>>>> Java Persistence with Hibernate, Second Edition
> > >>>>>>>>> <http://www.manning.com/bauer3/>
> > >>>>>>>>> JUnit in Action, Second Edition <
> > >>>> http://www.manning.com/tahchiev/>
> > >>>>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
> > >>>>>>>>> Blog: http://garygregory.wordpress.com
> > >>>>>>>>> Home: http://garygregory.com/
> > >>>>>>>>> Tweet! http://twitter.com/GaryGregory
> > >>>>>>>
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> --
> > >>>>>>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > >>>>>>> Java Persistence with Hibernate, Second Edition
> > >>>>>>> <http://www.manning.com/bauer3/>
> > >>>>>>> JUnit in Action, Second Edition <
> http://www.manning.com/tahchiev/>
> > >>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
> > >>>>>>> Blog: http://garygregory.wordpress.com
> > >>>>>>> Home: http://garygregory.com/
> > >>>>>>> Tweet! http://twitter.com/GaryGregory
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>> --
> > >>>>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > >>>>> Java Persistence with Hibernate, Second Edition
> > >>>>> <http://www.manning.com/bauer3/>
> > >>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > >>>>> Spring Batch in Action <http://www.manning.com/templier/>
> > >>>>> Blog: http://garygregory.wordpress.com
> > >>>>> Home: http://garygregory.com/
> > >>>>> Tweet! http://twitter.com/GaryGregory
> > >>>
> > >>>
> > >>>
> > >>> --
> > >>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > >>> Java Persistence with Hibernate, Second Edition
> > >>> <http://www.manning.com/bauer3/>
> > >>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > >>> Spring Batch in Action <http://www.manning.com/templier/>
> > >>> Blog: http://garygregory.wordpress.com
> > >>> Home: http://garygregory.com/
> > >>> Tweet! http://twitter.com/GaryGregory
> > >
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
>
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior backend developer

*Magine TV*
mikael.stal...@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: approach for defining loggers

2015-09-02 Thread Mikael Ståldal
> > > logging
> > > > > > > appender, and our custom level will go to another appender.
> > > Thoughts?
> > > > > > >
> > > > > > > Thanks,
> > > > > > > Nick
> > > > > > >
> > > > > > > > Subject: Re: approach for defining loggers
> > > > > > > > From: ralph.go...@dslextreme.com
> > > > > > > > Date: Sat, 29 Aug 2015 20:59:36 -0700
> > > > > > > > To: log4j-user@logging.apache.org
> > > > > > > >
> > > > > > > >
> > > > > > > > > On Aug 29, 2015, at 7:44 PM, Nicholas Duane <
> nic...@msn.com>
> > > > > wrote:
> > > > > > > > >
> > > > > > > > > I'm curious if there is a prescribed approach to defining
> > > loggers.
> > > > > > > Let me state what my assumption is.  I assume that normally if
> some
> > > > > piece
> > > > > > > of code wants to log events/messages that it should create a
> > > logger for
> > > > > > > itself.  I guess a reasonable name to use is the class name
> > > itself.  In
> > > > > > > terms of logger configuration I would expect that no loggers
> are
> > > > > specified
> > > > > > > in the log4j configuration UNLESS is needs settings other than
> the
> > > > > > > default.  The root logger would specify the default settings,
> eg.
> > > > > level and
> > > > > > > appenders.  If some piece of code tied to a logger needs to
> enable
> > > > > tracing
> > > > > > > in order to debug an issue then you would add that logger to
> the
> > > > > > > configuration and set the level less specific for that
> logger.  Is
> > > > > this a
> > > > > > > typical and reasonable approach?
> > > > > > > >
> > > > > > > > What you describe here is the common convention. It is a
> > > reasonable
> > > > > > > approach.
> > > > > > > >
> > > > > > > > >
> > > > > > > > > I asked because we have the need for a new type of event.
> To
> > > have
> > > > > > > this event flow to where we want it to flow the plan is to
> have a
> > > > > custom
> > > > > > > level and have all events at that level captured by a specific
> > > > > appender.
> > > > > > > My assumption was that for existing applications we'd just
> need to
> > > add
> > > > > our
> > > > > > > appender to the root and add our custom level.  The app would
> need
> > > to
> > > > > be
> > > > > > > modified to log our new event at the custom level.  However,
> > > someone
> > > > > > > suggested that we could also create a separate logger for this
> > > event.
> > > > > My
> > > > > > > thinking is that while we don't ever want to turn off logging
> of
> > > this
> > > > > > > event, loggers represent "event sources", e.g the code raising
> the
> > > > > events
> > > > > > > and thus having multiple different pieces of code use the same
> > > logger
> > > > > > > wouldn't allow you to turn on/off logging from those different
> > > > > sections of
> > > > > > > code independently.  I think the current configuration includes
> > > all the
> > > > > > > loggers.  Normally I would expect there to be many, on the
> order of
> > > > > 10's or
> > > > > > > 100's, loggers within an application.  However, in the case I
> was
> > > given
> > > > > > > there were only a handful because I think this handful is
> shared.
> > > So
> > > > > as I
> > > > > > > mentioned, this doesn't sound like an ideal design as you have
> less
> > > > > > > granularity on what you can turn on/off.
> > > > > > > >
> > > > > > > > You have a few options. Using a CustomLevel would not be the
> > > option I
> > > > > > > would choose.  Creating a custom Logger will certainly work and
> > > makes
> > > > > > > routing the message to the appropriate appender rather easy.
> > > Another
> > > > > > > approach is to use Markers.  Markers are somewhat hierarchical
> so
> > > you
> > > > > can
> > > > > > > use them for a variety of purposes.  If you look at how Log4j
> > > handles
> > > > > event
> > > > > > > logging it actually does both - it specifies EventLogger as the
> > > name
> > > > > of the
> > > > > > > logger to use and it uses Markers to identify the kind of
> event.
> > > > > > > >
> > > > > > > > A third option is to use the MDC or Logger properties. If
> you do
> > > that
> > > > > > > then you can have information included in the actual logging
> event
> > > > > that can
> > > > > > > affect how it is routed. I also built a system that uses the
> > > RFC5424
> > > > > format
> > > > > > > so that the event could have lots of key/value pairs to
> identify
> > > the
> > > > > events.
> > > > > > > >
> > > > > > > > Unfortunately, without knowing more details I don’t know
> that I
> > > can
> > > > > give
> > > > > > > you a better idea on how I would implement it.
> > > > > > > >
> > > > > > > > Ralph
> > > > > > > >
> > > > > > > >
> > > -
> > > > > > > > To unsubscribe, e-mail:
> > > log4j-user-unsubscr...@logging.apache.org
> > > > > > > > For additional commands, e-mail:
> > > log4j-user-h...@logging.apache.org
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > > > > > Java Persistence with Hibernate, Second Edition
> > > > > > <http://www.manning.com/bauer3/>
> > > > > > JUnit in Action, Second Edition <
> http://www.manning.com/tahchiev/>
> > > > > > Spring Batch in Action <http://www.manning.com/templier/>
> > > > > > Blog: http://garygregory.wordpress.com
> > > > > > Home: http://garygregory.com/
> > > > > > Tweet! http://twitter.com/GaryGregory
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > > > Java Persistence with Hibernate, Second Edition
> > > > <http://www.manning.com/bauer3/>
> > > > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > > > Spring Batch in Action <http://www.manning.com/templier/>
> > > > Blog: http://garygregory.wordpress.com
> > > > Home: http://garygregory.com/
> > > > Tweet! http://twitter.com/GaryGregory
> > >
> > >
> >
> >
> >
> > --
> > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > Java Persistence with Hibernate, Second Edition
> > <http://www.manning.com/bauer3/>
> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > Spring Batch in Action <http://www.manning.com/templier/>
> > Blog: http://garygregory.wordpress.com
> > Home: http://garygregory.com/
> > Tweet! http://twitter.com/GaryGregory
>
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior backend developer

*Magine TV*
mikael.stal...@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: approach for defining loggers

2015-09-09 Thread Mikael Ståldal
  Our plan, at least the one I have now in my
> head, is
> > > that we'll have some number of appenders in the root.  We'll then
> filter x
> > > < INFO events to a tracing appender, INFO <= x <= FATAL to a logging
> > > appender, and our custom level will go to another appender.  Thoughts?
> > > >>>>>
> > > >>>>> Thanks,
> > > >>>>> Nick
> > > >>>>>
> > > >>>>>> Subject: Re: approach for defining loggers
> > > >>>>>> From: ralph.go...@dslextreme.com
> > > >>>>>> Date: Sat, 29 Aug 2015 20:59:36 -0700
> > > >>>>>> To: log4j-user@logging.apache.org
> > > >>>>>>
> > > >>>>>>
> > > >>>>>>> On Aug 29, 2015, at 7:44 PM, Nicholas Duane 
> > > wrote:
> > > >>>>>>>
> > > >>>>>>> I'm curious if there is a prescribed approach to defining
> > > loggers.  Let me state what my assumption is.  I assume that normally
> if
> > > some piece of code wants to log events/messages that it should create a
> > > logger for itself.  I guess a reasonable name to use is the class name
> > > itself.  In terms of logger configuration I would expect that no
> loggers
> > > are specified in the log4j configuration UNLESS is needs settings other
> > > than the default.  The root logger would specify the default settings,
> eg.
> > > level and appenders.  If some piece of code tied to a logger needs to
> > > enable tracing in order to debug an issue then you would add that
> logger to
> > > the configuration and set the level less specific for that logger.  Is
> this
> > > a typical and reasonable approach?
> > > >>>>>>
> > > >>>>>> What you describe here is the common convention. It is a
> reasonable
> > > approach.
> > > >>>>>>
> > > >>>>>>>
> > > >>>>>>> I asked because we have the need for a new type of event.  To
> have
> > > this event flow to where we want it to flow the plan is to have a
> custom
> > > level and have all events at that level captured by a specific
> appender.
> > > My assumption was that for existing applications we'd just need to add
> our
> > > appender to the root and add our custom level.  The app would need to
> be
> > > modified to log our new event at the custom level.  However, someone
> > > suggested that we could also create a separate logger for this event.
> My
> > > thinking is that while we don't ever want to turn off logging of this
> > > event, loggers represent "event sources", e.g the code raising the
> events
> > > and thus having multiple different pieces of code use the same logger
> > > wouldn't allow you to turn on/off logging from those different
> sections of
> > > code independently.  I think the current configuration includes all the
> > > loggers.  Normally I would expect there to be many, on the order of
> 10's or
> > > 100's, loggers within an application.  However, in the case I was given
> > > there were only a handful because I think this handful is shared.  So
> as I
> > > mentioned, this doesn't sound like an ideal design as you have less
> > > granularity on what you can turn on/off.
> > > >>>>>>
> > > >>>>>> You have a few options. Using a CustomLevel would not be the
> option
> > > I would choose.  Creating a custom Logger will certainly work and makes
> > > routing the message to the appropriate appender rather easy.  Another
> > > approach is to use Markers.  Markers are somewhat hierarchical so you
> can
> > > use them for a variety of purposes.  If you look at how Log4j handles
> event
> > > logging it actually does both - it specifies EventLogger as the name
> of the
> > > logger to use and it uses Markers to identify the kind of event.
> > > >>>>>>
> > > >>>>>> A third option is to use the MDC or Logger properties. If you do
> > > that then you can have information included in the actual logging event
> > > that can affect how it is routed. I also built a system that uses the
> > > RFC5424 format so that the event could have lots of key/value pairs to
> > > identify the events.
> > > >>>>>>
> > > >>>>>> Unfortunately, without knowing more details I don’t know that I
> can
> > > give you a better idea on how I would implement it.
> > > >>>>>>
> > > >>>>>> Ralph
> > > >>>>>>
> > > >>>>>>
> > > -
> > > >>>>>> To unsubscribe, e-mail:
> log4j-user-unsubscr...@logging.apache.org
> > > >>>>>> For additional commands, e-mail:
> log4j-user-h...@logging.apache.org
> > > >>>>>>
> > > >>>>>
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>>
> -
> > > >>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > > >>>> For additional commands, e-mail:
> log4j-user-h...@logging.apache.org
> > > >>>>
> > > >>>
> > > >>
> > > >
> > > >
> > >
> > >
> > >
> > > -
> > > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> > >
> > >
> >
> >
> > --
> > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > Java Persistence with Hibernate, Second Edition
> > <http://www.manning.com/bauer3/>
> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > Spring Batch in Action <http://www.manning.com/templier/>
> > Blog: http://garygregory.wordpress.com
> > Home: http://garygregory.com/
> > Tweet! http://twitter.com/GaryGregory
>
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: markers

2015-09-17 Thread Mikael Ståldal
m
> > > To: log4j-user@logging.apache.org
> > > Subject: markers
> > > Date: Tue, 15 Sep 2015 22:25:37 -0400
> > >
> > >
> > >
> > >
> > > I was about to starting writing a sample to see how markers work and to
> > see if they could be used for logging business events instead of using a
> > custom level.  While I might have mentioned log4net in passing, we're
> > trying to capture these business events using existing logging
> frameworks.
> > The thinking is that we'd use log4net on windows and log4j(2) on linux
> (no
> > facade).  Ideally the design would be similar across both platforms.
> That
> > being said, I'm surprised at how different log4net is from log4j(2).  It
> > appears log4net doesn't support markers.  While we don't have to have the
> > same solution for both platforms, it would be nice if the solutions were
> > the same or similar.
> > >
> > > I also looked at the EventLogger and that class doesn't have any
> > overloads which take a marker, just a static marker property.  I guess
> the
> > EventLogger can be assigned only a single marker?
> > >
> > > Thanks,
> > > Nick
> > >
> > >
> > >
> > >
> >
> >
>
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Bizarre performance in log4j2

2015-10-13 Thread Mikael Ståldal
he.logging.log4j.core.config.LoggersPlugin. Going to try
> >>>> finding
> >>>>> a
> >>>>>> factory method instead.
> >>>>>> 2015-10-12 18:55:25,565 DEBUG Still building Plugin[name=loggers,
> >>>>>> class=org.apache.logging.log4j.core.config.LoggersPlugin]. Searching
> >>>> for
> >>>>>> factory method...
> >>>>>> 2015-10-12 18:55:25,565 DEBUG Found factory method [createLoggers]:
> >>>>> public
> >>>>>> static org.apache.logging.log4j.core.config.Loggers
> >>
> org.apache.logging.log4j.core.config.LoggersPlugin.createLoggers(org.apache.logging.log4j.core.config.LoggerConfig[]).
> >>>>>> 2015-10-12 18:55:25,566 DEBUG Calling createLoggers on class
> >>>>>> org.apache.logging.log4j.core.config.LoggersPlugin for element
> Loggers
> >>>>> with
> >>>>>> params(={root})
> >>>>>> 2015-10-12 18:55:25,566 DEBUG Built Plugin[name=loggers] OK from
> >>>> factory
> >>>>>> method.
> >>>>>> 2015-10-12 18:55:25,567 TRACE AsyncLoggerConfig[root] starting...
> >>>>>> 2015-10-12 18:55:25,574 TRACE AsyncLoggerConfigHelper creating new
> >>>>>> disruptor. Ref count is 1.
> >>>>>> 2015-10-12 18:55:25,574 DEBUG property
> >>>>> AsyncLoggerConfig.WaitStrategy=null
> >>>>>> 2015-10-12 18:55:25,575 DEBUG disruptor event handler uses
> >>>>>> BlockingWaitStrategy
> >>>>>> 2015-10-12 18:55:25,625 DEBUG Starting AsyncLoggerConfig disruptor
> >> with
> >>>>>> ringbuffer size=262144, waitStrategy=BlockingWaitStrategy,
> >>>>>> exceptionHandler=null...
> >>>>>> 2015-10-12 18:55:25,627 DEBUG Started configuration
> >>>>>> XmlConfiguration[location=jndi:/localhost/WEB-INF/log4j2.xml] OK.
> >>>>>> 2015-10-12 18:55:25,627 TRACE Stopping
> >>>>>> org.apache.logging.log4j.core.config.DefaultConfiguration@75c1ada7.
> ..
> >>>>>> 2015-10-12 18:55:25,628 TRACE AbstractConfiguration stopped 0
> >>>>>> AsyncLoggerConfigs.
> >>>>>> 2015-10-12 18:55:25,628 TRACE AbstractConfiguration stopped 0
> >>>>>> AsyncAppenders.
> >>>>>> 2015-10-12 18:55:25,628 TRACE AbstractConfiguration stopped 1
> >>>> Appenders.
> >>>>>> 2015-10-12 18:55:25,628 TRACE AbstractConfiguration stopped 0
> Loggers.
> >>>>>> 2015-10-12 18:55:25,629 DEBUG Stopped
> >>>>>> org.apache.logging.log4j.core.config.DefaultConfiguration@75c1ada7
> OK
> >>>>>> 2015-10-12 18:55:25,634 DEBUG Registering MBean
> >>>>>> org.apache.logging.log4j2:type=2090228673
> >>>>>> 2015-10-12 18:55:25,642 DEBUG Registering MBean
> >>>>>> org.apache.logging.log4j2:type=2090228673,component=StatusLogger
> >>>>>> 2015-10-12 18:55:25,647 DEBUG Registering MBean
> >>>>>> org.apache.logging.log4j2:type=2090228673,component=ContextSelector
> >>>>>> 2015-10-12 18:55:25,649 DEBUG Registering MBean
> >>>>>> org.apache.logging.log4j2:type=2090228673,component=Loggers,name=
> >>>>>> 2015-10-12 18:55:25,653 DEBUG Registering MBean
> >>
> org.apache.logging.log4j2:type=2090228673,component=Loggers,name=,subtype=RingBuffer
> >>>>>> 2015-10-12 18:55:25,657 DEBUG Registering MBean
> >>
> org.apache.logging.log4j2:type=2090228673,component=Appenders,name=STDOUT
> >>>>>> 2015-10-12 18:55:25,659 DEBUG Registering MBean
> >> org.apache.logging.log4j2:type=2090228673,component=Appenders,name=File
> >>>>>> 2015-10-12 18:55:25,660 DEBUG LoggerContext[name=2090228673,
> >>>>>> org.apache.logging.log4j.core.LoggerContext@4347ede7] started OK
> with
> >>>>>> configuration
> >>>>>> XmlConfiguration[location=jndi:/localhost/WEB-INF/log4j2.xml].
> >>>>>> 2015-10-12 18:55:26,198 DEBUG Starting RollingFileManager
> >>>>>> /data/applogs/pigeon/pigeon.data-proxy.log
> >>>>>> 2015-10-12 18:55:26,200 DEBUG PluginManager 'FileConverter' found 2
> >>>>> plugins
> >>>>>> 2015-10-12 18:55:26,203 TRACE PatternProcessor.getNextTime returning
> >>>>>> 2015/10/13-00:00:00.000, nextFileTime=2015/10/12-00:00:00.000,
> >>>>>> prevFileTime=1970/01/01-08:00:00.000,
> current=2015/10/12-18:55:26.202,
> >>>>>> freq=DAILY
> >>>>>> 2015-10-12 18:55:26,204 TRACE PatternProcessor.getNextTime returning
> >>>>>> 2015/10/13-00:00:00.000, nextFileTime=2015/10/12-00:00:00.000,
> >>>>>> prevFileTime=2015/10/12-00:00:00.000,
> current=2015/10/12-18:55:26.203,
> >>>>>> freq=DAILY
> >>>>>> 2015-10-12 18:55:26,204 DEBUG Starting OutputStreamManager
> SYSTEM_ERR
> >>>>>> 2015-10-12 18:55:26,207 DEBUG Starting RollingFileManager
> >>>>>> /data/applogs/pigeon/pigeon.data-proxy.access.log
> >>>>>> 2015-10-12 18:55:26,207 DEBUG PluginManager 'FileConverter' found 2
> >>>>> plugins
> >>>>>> 2015-10-12 18:55:26,208 TRACE PatternProcessor.getNextTime returning
> >>>>>> 2015/09/30-00:00:00.000, nextFileTime=2015/09/29-00:00:00.000,
> >>>>>> prevFileTime=1970/01/01-08:00:00.000,
> current=2015/10/12-18:55:26.208,
> >>>>>> freq=DAILY
> >>>>>> 2015-10-12 18:55:26,209 TRACE PatternProcessor.getNextTime returning
> >>>>>> 2015/09/30-00:00:00.000, nextFileTime=2015/09/29-00:00:00.000,
> >>>>>> prevFileTime=2015/09/29-00:00:00.000,
> current=2015/10/12-18:55:26.209,
> >>>>>> freq=DAILY
> >>>>>> 2015-10-12 18:55:26,239 DEBUG Using default SystemClock for
> timestamps
> >>>
> >>>
> >>>
> >>> --
> >>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> >>> Java Persistence with Hibernate, Second Edition
> >>> <http://www.manning.com/bauer3/>
> >>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> >>> Spring Batch in Action <http://www.manning.com/templier/>
> >>> Blog: http://garygregory.wordpress.com
> >>> Home: http://garygregory.com/
> >>> Tweet! http://twitter.com/GaryGregory
> >>
> >> -
> >> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> >> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >>
> >>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Regeringsgatan 25  | 111 53 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Does anyone use Log4j2 with Logstash?

2015-11-19 Thread Mikael Ståldal
Is is even necessary to add Logstash to the mix? I think that Log4j 2
should be able to whatever is necessary by itself without either Flume or
Logstash.


On Wed, Nov 18, 2015 at 10:56 PM, David KOCH  wrote:

> We use log4j2's SyslogAppender and a logstash UDP input source, works ok
> for us, no need to add Flume to the mix.
>
> /David
>
> On 18 November 2015 at 22:35, Matt Sicker  wrote:
>
> > Any experience with this? I was thinking of using Flume and the Flume
> > appender to route all my log messages to an ELK stack, but I was
> wondering
> > if there were other ways of doing this.
> >
> > --
> > Matt Sicker 
> >
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Does anyone use Log4j2 with Logstash?

2015-11-19 Thread Mikael Ståldal
At my previous work, we first used Log4j 2 and Graylog, and Logstash in
between. But then I developed GelfLayout (now part of log4j-core) and we
could configure Log4j 2 to send log events directly to Graylog, and
Logstash became unnecessary.

Can we do something similar with ELK (so that it become just "E-K")? Can we
develop an ElasticSearchAppender for Log4j 2?


On Thu, Nov 19, 2015 at 1:07 PM, Mikael Ståldal 
wrote:

> Is is even necessary to add Logstash to the mix? I think that Log4j 2
> should be able to whatever is necessary by itself without either Flume or
> Logstash.
>
>
> On Wed, Nov 18, 2015 at 10:56 PM, David KOCH  wrote:
>
>> We use log4j2's SyslogAppender and a logstash UDP input source, works ok
>> for us, no need to add Flume to the mix.
>>
>> /David
>>
>> On 18 November 2015 at 22:35, Matt Sicker  wrote:
>>
>> > Any experience with this? I was thinking of using Flume and the Flume
>> > appender to route all my log messages to an ELK stack, but I was
>> wondering
>> > if there were other ways of doing this.
>> >
>> > --
>> > Matt Sicker 
>> >
>>
>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.stal...@magine.com
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Does anyone use Log4j2 with Logstash?

2015-11-19 Thread Mikael Ståldal
ElasticSearch is not Amazon specific (even though they provide it as a
service), so I don't think it should be in an amazon module. You can run
ElasticSearch yourself without Amazon.


Re: StatusLogger

2015-11-23 Thread Mikael Ståldal
Perhaps you can use the FailoverAppender for this?

http://logging.apache.org/log4j/2.x/manual/appenders.html#FailoverAppender

On Fri, Nov 20, 2015 at 6:55 PM, Nicholas Duane  wrote:

> We're attempting to capture error, or info, events that our plugins
> raise.  For instance, we wrote a domain sockets appender.  If that domain
> sockets appender has trouble connecting to the domain socket we'd like to
> know about it.  In addition, we'd like to know about it centrally so that
> we don't have to monitor each of the boxes our code is running on.  We
> therefore have a "logging" appender which writes to an http endpoint.  The
> log messages our plugins emit will get forwarded to this logging appender
> (via the configuration) in hopes to get these issues to a central
> location.  Of course if the http appender has trouble communicating with
> the http endpoint there's not much we can report on that, though I guess we
> could write to the StatusLogger at that point.
>
> I hope I explained it well enough so that you understand what it is we're
> trying to do.
>
> Thanks,
> Nick
>
> > Subject: Re: StatusLogger
> > From: ralph.go...@dslextreme.com
> > Date: Fri, 20 Nov 2015 10:16:17 -0700
> > To: log4j-user@logging.apache.org
> >
> > What do you mean by “capture the events from our appenders”?  The
> StatusLogger is primarily used during configuration or to log errors that
> occur in the appender. If you are trying to capture the events being logged
> that sounds a bit odd as that is the purpose of an appender.
> >
> > If you want to capture all the Log4j status logger output you can
> specify a destination on the configuration element. The output will then be
> written to that location instead of to stdout.
> >
> > Ralph
> >
> > > On Nov 20, 2015, at 8:01 AM, Nicholas Duane  wrote:
> > >
> > > The code happens to be a log4j2 appender, so it sounds like you're
> saying we should be using the StatusLogger, correct?  The issue is that we
> want to capture the events from our appenders to a central location.
> > >
> > > Thanks,
> > > Nick
> > >
> > >> Subject: Re: StatusLogger
> > >> From: ralph.go...@dslextreme.com
> > >> Date: Thu, 19 Nov 2015 19:01:45 -0700
> > >> To: log4j-user@logging.apache.org
> > >>
> > >> Yes, the StatusLogger is how Log4j logs things that happen within
> Log4j itself. If you are writing plugins for Log4j those should also use
> the StatusLogger as they effectively become part of Log4j. If the are
> regular application code then they should not use the StatusLogger.
> > >>
> > >> Although the StatusLogger uses the same API as the Log4j API its
> implementation is quite different and much more limited in what can be done
> with the output.
> > >>
> > >> The StatusLogger implementation doesn’t have Appenders. Instead it
> has StatusListeners that receive the events. The only listeners provided
> with Log4j are the StatusConsoleListener, which writes events to stdout or
> a PrintStream, and StatusLoggerAdmin, which makes events available over JMX.
> > >>
> > >> Ralph
> > >>
> > >>
> > >>
> > >>> On Nov 19, 2015, at 6:33 PM, Nicholas Duane  wrote:
> > >>>
> > >>> I'm trying to get information on the StatusLogger.  I've searched
> and so far the log4j docs say:
> > >>>
> > >>> "Records events that occur in the logging system."
> > >>>
> > >>> There are also a bunch of articles related to people having problems
> with the StatusLogger.  I'm just looking to find out what it is.  It
> appears it's somewhat of an "internal" logger that log4j (log4j2) uses to
> log internal events.  One reason I'm looking into this is because I see
> some code in one of our projects in which the class is logging to the
> StatusLogger.  I assume we shouldn't be doing this.
> > >>>
> > >>> Is the StatusLogger used in log4j2?  In one post I read that the
> "status" attribute controls the level.  Can I set the appender for the
> StatusLogger?
> > >>>
> > >>> Thanks,
> > >>> Nick
> > >>>
> > >>
> > >>
> > >>
> > >> -
> > >> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > >> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> > >>
> > >
> >
> >
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
>
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Does anyone use Log4j2 with Logstash?

2015-11-24 Thread Mikael Ståldal
It is good if you can have one component less in your system.

On Mon, Nov 23, 2015 at 8:07 PM, David KOCH  wrote:

> There exists a full-fledged Java API for Elasticsearch. Still, I am not
> sure it's the best idea to lump all the intricacies of efficient indexing
> into ES into a log4j2 appender. Logstash does this well - there is a reason
> it is part of the Elastic family.
>
> /David
>
> On 23 November 2015 at 18:32, Matt Sicker  wrote:
>
> > ElasticSearch has a REST API for adding data which seems to be a rather
> > inefficient way to implement an appender.
> >
> > On 19 November 2015 at 13:36, Matt Sicker  wrote:
> >
> > > I just spoke with my friend who's pretty familiar with both Solr and
> > > ElasticSearch, and he points out that Solr usage might be a bit more
> > > convoluted due to how rigidly defined search indexes are compared to
> ES.
> > > It'd be like the difference between SQL and NoSQL.
> > >
> > > On 19 November 2015 at 12:28, Ralph Goers 
> > > wrote:
> > >
> > >> The only problem I have is with the number of integrations we could
> do.
> > >> ElasticSearch and Solr are similar, and Solr is an Apache project, so
> I
> > >> would expect we would want to support both if we support either.
> > >>
> > >> Ralph
> > >>
> > >> > On Nov 19, 2015, at 10:07 AM, Gary Gregory 
> > >> wrote:
> > >> >
> > >> > Amazon has a pretty rich ecosystem of stuff. Should this be in a new
> > >> > log4j-amazon module or in the core module? Does it fit in no-sql?
> > >> >
> > >> > Gary
> > >> > On Nov 19, 2015 6:29 AM, "Matt Sicker"  wrote:
> > >> >
> > >> >> An ElasticSearchAppender does sound useful. We use Log4j2 in all
> our
> > >> >> projects, so we don't really need to add middleware unless
> absolutely
> > >> >> necessary.
> > >> >>
> > >> >> On 19 November 2015 at 07:35, Mikael Ståldal <
> > >> mikael.stal...@magine.com>
> > >> >> wrote:
> > >> >>
> > >> >>> At my previous work, we first used Log4j 2 and Graylog, and
> Logstash
> > >> in
> > >> >>> between. But then I developed GelfLayout (now part of log4j-core)
> > and
> > >> we
> > >> >>> could configure Log4j 2 to send log events directly to Graylog,
> and
> > >> >>> Logstash became unnecessary.
> > >> >>>
> > >> >>> Can we do something similar with ELK (so that it become just
> "E-K")?
> > >> Can
> > >> >> we
> > >> >>> develop an ElasticSearchAppender for Log4j 2?
> > >> >>>
> > >> >>>
> > >> >>> On Thu, Nov 19, 2015 at 1:07 PM, Mikael Ståldal <
> > >> >> mikael.stal...@magine.com
> > >> >>>>
> > >> >>> wrote:
> > >> >>>
> > >> >>>> Is is even necessary to add Logstash to the mix? I think that
> > Log4j 2
> > >> >>>> should be able to whatever is necessary by itself without either
> > >> Flume
> > >> >> or
> > >> >>>> Logstash.
> > >> >>>>
> > >> >>>>
> > >> >>>> On Wed, Nov 18, 2015 at 10:56 PM, David KOCH 
> > >> wrote:
> > >> >>>>
> > >> >>>>> We use log4j2's SyslogAppender and a logstash UDP input source,
> > >> works
> > >> >> ok
> > >> >>>>> for us, no need to add Flume to the mix.
> > >> >>>>>
> > >> >>>>> /David
> > >> >>>>>
> > >> >>>>> On 18 November 2015 at 22:35, Matt Sicker 
> > wrote:
> > >> >>>>>
> > >> >>>>>> Any experience with this? I was thinking of using Flume and the
> > >> >> Flume
> > >> >>>>>> appender to route all my log messages to an ELK stack, but I
> was
> > >> >>>>> wondering
> > >> >>>>>> if there were other ways of doing this.
> > >> >>>>>>
> > >> >>>>>> --
> > >&

Re: Does anyone use Log4j2 with Logstash?

2015-11-25 Thread Mikael Ståldal
I am using AsyncAppender to wrap KafkaAppender, it works fine. Consider
setting blocking="false" and shutdownTimeout on the AsyncAppender.

I have not tried async loggers, it might work as well.

I would recommend to always wrap appenders which make synchronous networks
requests with AsyncAppender or async logger.

On Tue, Nov 24, 2015 at 7:39 PM, Matt Sicker  wrote:

> Would using an async logger combine well with an HTTP appender like that?
> Because making a REST API for this sort of thing really sounds like a
> bottleneck.
>
> On 24 November 2015 at 02:42, Mikael Ståldal 
> wrote:
>
> > It is good if you can have one component less in your system.
> >
> > On Mon, Nov 23, 2015 at 8:07 PM, David KOCH  wrote:
> >
> > > There exists a full-fledged Java API for Elasticsearch. Still, I am not
> > > sure it's the best idea to lump all the intricacies of efficient
> indexing
> > > into ES into a log4j2 appender. Logstash does this well - there is a
> > reason
> > > it is part of the Elastic family.
> > >
> > > /David
> > >
> > > On 23 November 2015 at 18:32, Matt Sicker  wrote:
> > >
> > > > ElasticSearch has a REST API for adding data which seems to be a
> rather
> > > > inefficient way to implement an appender.
> > > >
> > > > On 19 November 2015 at 13:36, Matt Sicker  wrote:
> > > >
> > > > > I just spoke with my friend who's pretty familiar with both Solr
> and
> > > > > ElasticSearch, and he points out that Solr usage might be a bit
> more
> > > > > convoluted due to how rigidly defined search indexes are compared
> to
> > > ES.
> > > > > It'd be like the difference between SQL and NoSQL.
> > > > >
> > > > > On 19 November 2015 at 12:28, Ralph Goers <
> > ralph.go...@dslextreme.com>
> > > > > wrote:
> > > > >
> > > > >> The only problem I have is with the number of integrations we
> could
> > > do.
> > > > >> ElasticSearch and Solr are similar, and Solr is an Apache project,
> > so
> > > I
> > > > >> would expect we would want to support both if we support either.
> > > > >>
> > > > >> Ralph
> > > > >>
> > > > >> > On Nov 19, 2015, at 10:07 AM, Gary Gregory <
> > garydgreg...@gmail.com>
> > > > >> wrote:
> > > > >> >
> > > > >> > Amazon has a pretty rich ecosystem of stuff. Should this be in a
> > new
> > > > >> > log4j-amazon module or in the core module? Does it fit in
> no-sql?
> > > > >> >
> > > > >> > Gary
> > > > >> > On Nov 19, 2015 6:29 AM, "Matt Sicker" 
> wrote:
> > > > >> >
> > > > >> >> An ElasticSearchAppender does sound useful. We use Log4j2 in
> all
> > > our
> > > > >> >> projects, so we don't really need to add middleware unless
> > > absolutely
> > > > >> >> necessary.
> > > > >> >>
> > > > >> >> On 19 November 2015 at 07:35, Mikael Ståldal <
> > > > >> mikael.stal...@magine.com>
> > > > >> >> wrote:
> > > > >> >>
> > > > >> >>> At my previous work, we first used Log4j 2 and Graylog, and
> > > Logstash
> > > > >> in
> > > > >> >>> between. But then I developed GelfLayout (now part of
> > log4j-core)
> > > > and
> > > > >> we
> > > > >> >>> could configure Log4j 2 to send log events directly to
> Graylog,
> > > and
> > > > >> >>> Logstash became unnecessary.
> > > > >> >>>
> > > > >> >>> Can we do something similar with ELK (so that it become just
> > > "E-K")?
> > > > >> Can
> > > > >> >> we
> > > > >> >>> develop an ElasticSearchAppender for Log4j 2?
> > > > >> >>>
> > > > >> >>>
> > > > >> >>> On Thu, Nov 19, 2015 at 1:07 PM, Mikael Ståldal <
> > > > >> >> mikael.stal...@magine.com
> > > > >> >>>>
> > > > >> >>> wrote:
> > > > >> >>>
> &

Re: Does anyone use Log4j2 with Logstash?

2015-11-25 Thread Mikael Ståldal
Yes probably. But it is still a network request to a remote server.

On Wed, Nov 25, 2015 at 4:07 PM, Matt Sicker  wrote:

> Isn't Kafka like a lot faster than HTTP?
>
> On 25 November 2015 at 02:47, Mikael Ståldal 
> wrote:
>
> > I am using AsyncAppender to wrap KafkaAppender, it works fine. Consider
> > setting blocking="false" and shutdownTimeout on the AsyncAppender.
> >
> > I have not tried async loggers, it might work as well.
> >
> > I would recommend to always wrap appenders which make synchronous
> networks
> > requests with AsyncAppender or async logger.
> >
> > On Tue, Nov 24, 2015 at 7:39 PM, Matt Sicker  wrote:
> >
> > > Would using an async logger combine well with an HTTP appender like
> that?
> > > Because making a REST API for this sort of thing really sounds like a
> > > bottleneck.
> > >
> > > On 24 November 2015 at 02:42, Mikael Ståldal <
> mikael.stal...@magine.com>
> > > wrote:
> > >
> > > > It is good if you can have one component less in your system.
> > > >
> > > > On Mon, Nov 23, 2015 at 8:07 PM, David KOCH 
> wrote:
> > > >
> > > > > There exists a full-fledged Java API for Elasticsearch. Still, I am
> > not
> > > > > sure it's the best idea to lump all the intricacies of efficient
> > > indexing
> > > > > into ES into a log4j2 appender. Logstash does this well - there is
> a
> > > > reason
> > > > > it is part of the Elastic family.
> > > > >
> > > > > /David
> > > > >
> > > > > On 23 November 2015 at 18:32, Matt Sicker 
> wrote:
> > > > >
> > > > > > ElasticSearch has a REST API for adding data which seems to be a
> > > rather
> > > > > > inefficient way to implement an appender.
> > > > > >
> > > > > > On 19 November 2015 at 13:36, Matt Sicker 
> > wrote:
> > > > > >
> > > > > > > I just spoke with my friend who's pretty familiar with both
> Solr
> > > and
> > > > > > > ElasticSearch, and he points out that Solr usage might be a bit
> > > more
> > > > > > > convoluted due to how rigidly defined search indexes are
> compared
> > > to
> > > > > ES.
> > > > > > > It'd be like the difference between SQL and NoSQL.
> > > > > > >
> > > > > > > On 19 November 2015 at 12:28, Ralph Goers <
> > > > ralph.go...@dslextreme.com>
> > > > > > > wrote:
> > > > > > >
> > > > > > >> The only problem I have is with the number of integrations we
> > > could
> > > > > do.
> > > > > > >> ElasticSearch and Solr are similar, and Solr is an Apache
> > project,
> > > > so
> > > > > I
> > > > > > >> would expect we would want to support both if we support
> either.
> > > > > > >>
> > > > > > >> Ralph
> > > > > > >>
> > > > > > >> > On Nov 19, 2015, at 10:07 AM, Gary Gregory <
> > > > garydgreg...@gmail.com>
> > > > > > >> wrote:
> > > > > > >> >
> > > > > > >> > Amazon has a pretty rich ecosystem of stuff. Should this be
> > in a
> > > > new
> > > > > > >> > log4j-amazon module or in the core module? Does it fit in
> > > no-sql?
> > > > > > >> >
> > > > > > >> > Gary
> > > > > > >> > On Nov 19, 2015 6:29 AM, "Matt Sicker" 
> > > wrote:
> > > > > > >> >
> > > > > > >> >> An ElasticSearchAppender does sound useful. We use Log4j2
> in
> > > all
> > > > > our
> > > > > > >> >> projects, so we don't really need to add middleware unless
> > > > > absolutely
> > > > > > >> >> necessary.
> > > > > > >> >>
> > > > > > >> >> On 19 November 2015 at 07:35, Mikael Ståldal <
> > > > > > >> mikael.stal...@magine.com>
> > > > > > >> >> wrote:
> > > > > > >> >>
> > > > > > >> >>

Re: Appender's append() method

2016-01-14 Thread Mikael Ståldal
I might be a good idea to allow Appenders to throw any exception. Having to
catch and wrap checked exceptions is annoying.

On Thu, Jan 14, 2016 at 6:50 AM, Ralph Goers 
wrote:

> Why are you catching it at all? AppenderControl also takes care of
> handling logging the exception so you don’t even have to catch the
> exception to do that.
>
> Ralph
>
> > On Jan 13, 2016, at 7:49 PM, Nicholas Duane  wrote:
> >
> > Also, why would we not just rethrow whatever exception we caught?
> >
> > Thanks,
> > Nick
> >
> >> Subject: Re: Appender's append() method
> >> From: ralph.go...@dslextreme.com
> >> Date: Wed, 13 Jan 2016 17:28:11 -0700
> >> To: log4j-user@logging.apache.org
> >>
> >> Sorry, that was what I meant.
> >>
> >> Ralph
> >>
> >>> On Jan 13, 2016, at 3:17 PM, Gary Gregory 
> wrote:
> >>>
> >>> IMO a RuntimeException subclass is appropriate while RuntimeException
> >>> should not be used.
> >>>
> >>> Gary
> >>>
> >>> On Wed, Jan 13, 2016 at 1:53 PM, Ralph Goers <
> ralph.go...@dslextreme.com>
> >>> wrote:
> >>>
> >>>> Your appender is automatically wrapped by an AppenderControl object.
> The
> >>>> AppenderControl will inspect the ignoreExceptions flag so your
> Appender
> >>>> does not have to.  Your Appender should just throw a RuntimeException
> if it
> >>>> encounters a problem.
> >>>>
> >>>> Ralph
> >>>>
> >>>>> On Jan 13, 2016, at 2:38 PM, Nicholas Duane  wrote:
> >>>>>
> >>>>> I'm new to java so maybe this should be an obvious question to most
> java
> >>>> developers.  If I'm trying to override the append() method but also
> throw
> >>>> exceptions, how is that done?
> >>>>>
> >>>>> I'm asking because I assume my append method's outermost catch block
> is
> >>>> to inspect the ignoreExceptions flag and either bubble up the
> exception if
> >>>> ignoreExceptions is false or eat the exception otherwise, most likely
> just
> >>>> logging an event.  Is that true?  If so, then how do I accomplish
> that?  I
> >>>> tried coding it as I mentioned above (actually someone else did it
> for me),
> >>>> but the compiler I guess was complaining about the throw needing to
> be in a
> >>>> catch block, I assume because the append() method is not defined to
> throw
> >>>> exceptions.
> >>>>>
> >>>>> In addition, looking at what I think was source for one of your
> >>>> appenders at:
> >>>>>
> >>>>>
> >>>>
> https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;a=blob;f=log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractOutputStreamAppender.java;h=9a4cfde83194c866c30c4687e9f4ebb19cb20a17;hb=75d33d96ac00356014cf11f8ad9e8c6ead4db37a
> >>>>>
> >>>>> Why does it always throw an exception in the catch block instead of
> >>>> checking the state of the ignoreExceptions flag?
> >>>>>
> >>>>> Thanks,
> >>>>> Nick
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>> -
> >>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> >>>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> >>> Java Persistence with Hibernate, Second Edition
> >>> <http://www.manning.com/bauer3/>
> >>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> >>> Spring Batch in Action <http://www.manning.com/templier/>
> >>> Blog: http://garygregory.wordpress.com
> >>> Home: http://garygregory.com/
> >>> Tweet! http://twitter.com/GaryGregory
> >>
> >>
> >>
> >> -
> >> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> >> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >>
> >
>
>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Appender's append() method

2016-01-14 Thread Mikael Ståldal
I guess that AppenderLoggingException can be used for that purpose.

On Wed, Jan 13, 2016 at 10:53 PM, Ralph Goers 
wrote:

> Your appender is automatically wrapped by an AppenderControl object. The
> AppenderControl will inspect the ignoreExceptions flag so your Appender
> does not have to.  Your Appender should just throw a RuntimeException if it
> encounters a problem.
>
> Ralph
>
> > On Jan 13, 2016, at 2:38 PM, Nicholas Duane  wrote:
> >
> > I'm new to java so maybe this should be an obvious question to most java
> developers.  If I'm trying to override the append() method but also throw
> exceptions, how is that done?
> >
> > I'm asking because I assume my append method's outermost catch block is
> to inspect the ignoreExceptions flag and either bubble up the exception if
> ignoreExceptions is false or eat the exception otherwise, most likely just
> logging an event.  Is that true?  If so, then how do I accomplish that?  I
> tried coding it as I mentioned above (actually someone else did it for me),
> but the compiler I guess was complaining about the throw needing to be in a
> catch block, I assume because the append() method is not defined to throw
> exceptions.
> >
> > In addition, looking at what I think was source for one of your
> appenders at:
> >
> >
> https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;a=blob;f=log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractOutputStreamAppender.java;h=9a4cfde83194c866c30c4687e9f4ebb19cb20a17;hb=75d33d96ac00356014cf11f8ad9e8c6ead4db37a
> >
> > Why does it always throw an exception in the catch block instead of
> checking the state of the ignoreExceptions flag?
> >
> > Thanks,
> > Nick
> >
>
>
>
> ---------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Getter method for retrieving the attributes of an appender from the LoggerContext

2016-01-27 Thread Mikael Ståldal
pender;
> > >>>>>>>>>>
> > >>>>>>>>>> normally you would probably use instanceof to verify it is
> > >>>> actually
> > >>>>> a
> > >>>>>>>>>> SyslogAppender.
> > >>>>>>>>>>
> > >>>>>>>>>> Once you have that you can call whatever methods the
> > >>>> SyslogAppender
> > >>>>>>>>>> exposes for getting its attributes. They are not stored in a
> > >> Map
> > >>>>>>>> however,
> > >>>>>>>>>> so you can’t just call a generic getAttribute method.
> > >>>>>>>>>>
> > >>>>>>>>>> Ralph
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>>> On Jan 26, 2016, at 11:58 AM, Apostolis Giannakidis <
> > >>>>>>>>>> ap.giannaki...@gmail.com> wrote:
> > >>>>>>>>>>>
> > >>>>>>>>>>> Hello team,
> > >>>>>>>>>>>
> > >>>>>>>>>>> I have created a logger with an appender using the
> > >>>>>>>> ConfigurationBuilder
> > >>>>>>>>>> and
> > >>>>>>>>>>> the AppenderComponentBuilder.
> > >>>>>>>>>>>
> > >>>>>>>>>>> Let's say that this is how I create my appender:
> > >>>>>>>>>>>
> > >>>>>>>>>>> AppenderComponentBuilder appenderBuilder =
> > >>>>>>>>>>>  builder.newAppender( "syslogAppender",
> > >> "Syslog" )
> > >>>>>>>>>>>  .addAttribute( "protocol", "TCP" )
> > >>>>>>>>>>>  .addAttribute( "host", "localhost" )
> > >>>>>>>>>>>  .addAttribute( "port", 514 )
> > >>>>>>>>>>>  .addAttribute( "facility", "LOCAL2" )
> > >>>>>>>>>>>  .addAttribute( "immediateFlush", true )
> > >>>>>>>>>>>  .addAttribute( "newLine", true );
> > >>>>>>>>>>>
> > >>>>>>>>>>> Then, after I finish creating the builder I use the
> > >>>>>>>>>>> Configurator.initialize( builder.build() ) to get the
> > >>>>> LoggerContext.
> > >>>>>>>>>>>
> > >>>>>>>>>>> Is there any way I can access the attributes of the appender
> > >>>>> through
> > >>>>>>>>> the
> > >>>>>>>>>>> LoggerContext?
> > >>>>>>>>>>>
> > >>>>>>>>>>> For example something like this:
> > >>>>>>>>>>>
> > >>>>>>>>>>> LoggerContext ctx = Configurator.initialize( builder.build()
> > >> );
> > >>>>>>>>>>>
> > >>>>>>>>>>> String hostname =
> > >>>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>
> > >>>>>>
> > >>>>>
> > >>>>
> > >>>
> > >>
> >
> ctx.getConfiguration()..getAppenders().get("syslogAppender").getAttribute("host");
> > >>>>>>>>>>>
> > >>>>>>>>>>> Thank you all very much for your help.
> > >>>>>>>>>>>
> > >>>>>>>>>>> Apostolis
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>
> -
> > >>>>>>>>>> To unsubscribe, e-mail:
> > >>> log4j-user-unsubscr...@logging.apache.org
> > >>>>>>>>>> For additional commands, e-mail:
> > >>>> log4j-user-h...@logging.apache.org
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>> --
> > >>>>>>>> Matt Sicker 
> > >>>>>>>>
> > >>>>>>>
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> --
> > >>>>>>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > >>>>>>> Java Persistence with Hibernate, Second Edition
> > >>>>>>> <http://www.manning.com/bauer3/>
> > >>>>>>> JUnit in Action, Second Edition <
> > >> http://www.manning.com/tahchiev/>
> > >>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
> > >>>>>>> Blog: http://garygregory.wordpress.com
> > >>>>>>> Home: http://garygregory.com/
> > >>>>>>> Tweet! http://twitter.com/GaryGregory
> > >>>>>>
> > >>>>>>
> > >>>>>>
> > >>>>>>
> > >> -
> > >>>>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > >>>>>> For additional commands, e-mail:
> > >> log4j-user-h...@logging.apache.org
> > >>>>>>
> > >>>>>>
> > >>>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>> --
> > >>>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > >>>> Java Persistence with Hibernate, Second Edition
> > >>>> <http://www.manning.com/bauer3/>
> > >>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > >>>> Spring Batch in Action <http://www.manning.com/templier/>
> > >>>> Blog: http://garygregory.wordpress.com
> > >>>> Home: http://garygregory.com/
> > >>>> Tweet! http://twitter.com/GaryGregory
> > >>>>
> > >>>
> > >>
> > >>
> > >>
> > >> --
> > >> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > >> Java Persistence with Hibernate, Second Edition
> > >> <http://www.manning.com/bauer3/>
> > >> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > >> Spring Batch in Action <http://www.manning.com/templier/>
> > >> Blog: http://garygregory.wordpress.com
> > >> Home: http://garygregory.com/
> > >> Tweet! http://twitter.com/GaryGregory
> > >>
> >
> >
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Getter method for retrieving the attributes of an appender from the LoggerContext

2016-01-27 Thread Mikael Ståldal
Then perhaps we should keep the node tree and expose it for this kind of
queries, something like this:

String hostname = loggerContext.getConfiguration().
getAttributesForAppender("syslogAppender").get("host");

This would require a new method in
org.apache.logging.log4j.core.config.Configuration:

public Map getAttributesForAppender(String appenderName);



On Wed, Jan 27, 2016 at 1:27 PM, Ralph Goers 
wrote:

> While I understand your point, the node tree is discarded after the
> plugins are created. We would have to keep it around for this to work.
> Furthermore, each component would need to have a reference to its
> corresponding node, which we obviously don't currently do.
>
> Ralph
>
> > On Jan 27, 2016, at 2:33 AM, Mikael Ståldal 
> wrote:
> >
> > To me it does not seems good to force all Appender implementations to
> > implement this. Especially not since the next logical step would then be
> to
> > do the same with other components such as Layouts. That would be a lot of
> > work in total, and also add more work for all future components,
> including
> > 3rd party plugins.
> >
> > I think it makes more sense, and would be less work in total, if the
> > configuration system would store and expose those attributes without
> > involving the components themselves.
> >
> > On Wed, Jan 27, 2016 at 7:14 AM, Gary Gregory 
> > wrote:
> >
> >> Apostolis,
> >>
> >> You are warmly welcome to contribute to Log4j. You can create a JIRA and
> >> attach a patch in unified diff file format. Unit tests as part of the
> patch
> >> are a must IMO. Feel free to flush out any design or implementation
> here on
> >> the dev ML.
> >>
> >> Thank you!
> >> Gary
> >>
> >> On Tue, Jan 26, 2016 at 5:02 PM, Ralph Goers <
> ralph.go...@dslextreme.com>
> >> wrote:
> >>
> >>> All the attributes have to have String representations to be usable in
> >> the
> >>> XML, JSON & Properties configurations. Yes, the Map could contain
> Objects
> >>> but then every one of them has to be cast to its real object to be
> >> usable.
> >>>
> >>> The map should be read-only because modifying its contents would have
> no
> >>> effect on the appender.
> >>>
> >>> The map should not be stored in an ivar but constructed whenever the
> >>> attributes are retrieved. Otherwise it will be temping to just keep
> them
> >> in
> >>> a map and not as individual attributes, which would cause problems.
> >>>
> >>> If you have nesting such as  MyAppender extends MyBaseAppender extends
> >>> AbstractOutputStreamAppender extends AbstractAppender, I envision a
> >>> fillAttributes method at each “level” that fills in the attributes it
> >> knows
> >>> about, so fillAttributeMap(map) should always call
> >>> super.fillAttributeMap(map) - except in AbstractAppender of course -
> and
> >>> should call it before filling in its own attributes so that it can
> >> override
> >>> any values provided by the base Appenders.  If the primary Appender
> does
> >>> not implement fillAttributeMap then only the attributes of its super
> >>> classes will be included, which is actually correct for the
> >> SyslogAppender.
> >>>
> >>> Ralph
> >>>
> >>>> On Jan 26, 2016, at 5:24 PM, Apostolis Giannakidis <
> >>> ap.giannaki...@gmail.com> wrote:
> >>>>
> >>>> One thing to note here. Correct me if I am wrong, but the map should
> >>>> be Map >>>> Object> because not all attributes are Strings. From the top of my
> >> head,
> >>> I
> >>>> know that an attribute could also be a boolean.
> >>>>
> >>>> On Wed, Jan 27, 2016 at 12:06 AM, Gary Gregory <
> garydgreg...@gmail.com
> >>>
> >>>> wrote:
> >>>>
> >>>>> I could see AbstractAppender implementing a getAttributes() method
> >> like
> >>>>> this:
> >>>>>
> >>>>>   public Map getAttributes() {
> >>>>>   Map map = new HashMap<>();
> >>>>>   fillAttributeMap(map);
> >>>>>   // (1) should the map be read-only? why?
> >>>>>   // (2) if the map is cached in an ivar, the it must be updated
> >> by
> >>>>> each appender when

Re: Getter method for retrieving the attributes of an appender from the LoggerContext

2016-01-27 Thread Mikael Ståldal
I don't quite understand what you mean.

On Wed, Jan 27, 2016 at 4:02 PM, Matt Sicker  wrote:

> That sounds a little fragile as some people either create or modify their
> creation directly from the plugin factories.
>
> On 27 January 2016 at 07:05, Mikael Ståldal 
> wrote:
>
> > Then perhaps we should keep the node tree and expose it for this kind of
> > queries, something like this:
> >
> > String hostname = loggerContext.getConfiguration().
> > getAttributesForAppender("syslogAppender").get("host");
> >
> > This would require a new method in
> > org.apache.logging.log4j.core.config.Configuration:
> >
> > public Map getAttributesForAppender(String appenderName);
> >
> >
> >
> > On Wed, Jan 27, 2016 at 1:27 PM, Ralph Goers  >
> > wrote:
> >
> > > While I understand your point, the node tree is discarded after the
> > > plugins are created. We would have to keep it around for this to work.
> > > Furthermore, each component would need to have a reference to its
> > > corresponding node, which we obviously don't currently do.
> > >
> > > Ralph
> > >
> > > > On Jan 27, 2016, at 2:33 AM, Mikael Ståldal <
> mikael.stal...@magine.com
> > >
> > > wrote:
> > > >
> > > > To me it does not seems good to force all Appender implementations to
> > > > implement this. Especially not since the next logical step would then
> > be
> > > to
> > > > do the same with other components such as Layouts. That would be a
> lot
> > of
> > > > work in total, and also add more work for all future components,
> > > including
> > > > 3rd party plugins.
> > > >
> > > > I think it makes more sense, and would be less work in total, if the
> > > > configuration system would store and expose those attributes without
> > > > involving the components themselves.
> > > >
> > > > On Wed, Jan 27, 2016 at 7:14 AM, Gary Gregory <
> garydgreg...@gmail.com>
> > > > wrote:
> > > >
> > > >> Apostolis,
> > > >>
> > > >> You are warmly welcome to contribute to Log4j. You can create a JIRA
> > and
> > > >> attach a patch in unified diff file format. Unit tests as part of
> the
> > > patch
> > > >> are a must IMO. Feel free to flush out any design or implementation
> > > here on
> > > >> the dev ML.
> > > >>
> > > >> Thank you!
> > > >> Gary
> > > >>
> > > >> On Tue, Jan 26, 2016 at 5:02 PM, Ralph Goers <
> > > ralph.go...@dslextreme.com>
> > > >> wrote:
> > > >>
> > > >>> All the attributes have to have String representations to be usable
> > in
> > > >> the
> > > >>> XML, JSON & Properties configurations. Yes, the Map could contain
> > > Objects
> > > >>> but then every one of them has to be cast to its real object to be
> > > >> usable.
> > > >>>
> > > >>> The map should be read-only because modifying its contents would
> have
> > > no
> > > >>> effect on the appender.
> > > >>>
> > > >>> The map should not be stored in an ivar but constructed whenever
> the
> > > >>> attributes are retrieved. Otherwise it will be temping to just keep
> > > them
> > > >> in
> > > >>> a map and not as individual attributes, which would cause problems.
> > > >>>
> > > >>> If you have nesting such as  MyAppender extends MyBaseAppender
> > extends
> > > >>> AbstractOutputStreamAppender extends AbstractAppender, I envision a
> > > >>> fillAttributes method at each “level” that fills in the attributes
> it
> > > >> knows
> > > >>> about, so fillAttributeMap(map) should always call
> > > >>> super.fillAttributeMap(map) - except in AbstractAppender of course
> -
> > > and
> > > >>> should call it before filling in its own attributes so that it can
> > > >> override
> > > >>> any values provided by the base Appenders.  If the primary Appender
> > > does
> > > >>> not implement fillAttributeMap then only the attributes of its
> super
> > > >>> c

Re: Getter method for retrieving the attributes of an appender from the LoggerContext

2016-01-27 Thread Mikael Ståldal
It would be useful if Apostolis Giannakidis can explain the use case behind
this request, now it is a bit abstract to me.

On Wed, Jan 27, 2016 at 4:13 PM, Matt Sicker  wrote:

> I mean keeping the Node tree to get attributes. It would only work from
> config files (and the config builder classes). We get questions every so
> often about modifying the config programmatically which would either need
> to maintain more Nodes or just be unsupported.
>
> On 27 January 2016 at 09:09, Mikael Ståldal 
> wrote:
>
> > I don't quite understand what you mean.
> >
> > On Wed, Jan 27, 2016 at 4:02 PM, Matt Sicker  wrote:
> >
> > > That sounds a little fragile as some people either create or modify
> their
> > > creation directly from the plugin factories.
> > >
> > > On 27 January 2016 at 07:05, Mikael Ståldal  >
> > > wrote:
> > >
> > > > Then perhaps we should keep the node tree and expose it for this kind
> > of
> > > > queries, something like this:
> > > >
> > > > String hostname = loggerContext.getConfiguration().
> > > > getAttributesForAppender("syslogAppender").get("host");
> > > >
> > > > This would require a new method in
> > > > org.apache.logging.log4j.core.config.Configuration:
> > > >
> > > > public Map getAttributesForAppender(String
> > appenderName);
> > > >
> > > >
> > > >
> > > > On Wed, Jan 27, 2016 at 1:27 PM, Ralph Goers <
> > ralph.go...@dslextreme.com
> > > >
> > > > wrote:
> > > >
> > > > > While I understand your point, the node tree is discarded after the
> > > > > plugins are created. We would have to keep it around for this to
> > work.
> > > > > Furthermore, each component would need to have a reference to its
> > > > > corresponding node, which we obviously don't currently do.
> > > > >
> > > > > Ralph
> > > > >
> > > > > > On Jan 27, 2016, at 2:33 AM, Mikael Ståldal <
> > > mikael.stal...@magine.com
> > > > >
> > > > > wrote:
> > > > > >
> > > > > > To me it does not seems good to force all Appender
> implementations
> > to
> > > > > > implement this. Especially not since the next logical step would
> > then
> > > > be
> > > > > to
> > > > > > do the same with other components such as Layouts. That would be
> a
> > > lot
> > > > of
> > > > > > work in total, and also add more work for all future components,
> > > > > including
> > > > > > 3rd party plugins.
> > > > > >
> > > > > > I think it makes more sense, and would be less work in total, if
> > the
> > > > > > configuration system would store and expose those attributes
> > without
> > > > > > involving the components themselves.
> > > > > >
> > > > > > On Wed, Jan 27, 2016 at 7:14 AM, Gary Gregory <
> > > garydgreg...@gmail.com>
> > > > > > wrote:
> > > > > >
> > > > > >> Apostolis,
> > > > > >>
> > > > > >> You are warmly welcome to contribute to Log4j. You can create a
> > JIRA
> > > > and
> > > > > >> attach a patch in unified diff file format. Unit tests as part
> of
> > > the
> > > > > patch
> > > > > >> are a must IMO. Feel free to flush out any design or
> > implementation
> > > > > here on
> > > > > >> the dev ML.
> > > > > >>
> > > > > >> Thank you!
> > > > > >> Gary
> > > > > >>
> > > > > >> On Tue, Jan 26, 2016 at 5:02 PM, Ralph Goers <
> > > > > ralph.go...@dslextreme.com>
> > > > > >> wrote:
> > > > > >>
> > > > > >>> All the attributes have to have String representations to be
> > usable
> > > > in
> > > > > >> the
> > > > > >>> XML, JSON & Properties configurations. Yes, the Map could
> contain
> > > > > Objects
> > > > > >>> but then every one of them has to be cast to its real object to
> > be
> > > > > >> usable.
> > >

Re: Getter method for retrieving the attributes of an appender from the LoggerContext

2016-01-27 Thread Mikael Ståldal
OK, then the keeping config nodes approach might not be a good idea.

However, I still don't think that the benefit of being able to inspect
appender's config justifies the cost of increasing the complexity of every
appender (including future ones and 3rd party plugins).

On Wed, Jan 27, 2016 at 4:22 PM, Apostolis Giannakidis <
ap.giannaki...@gmail.com> wrote:

> One use case that I have at hand at the moment is that I want to be able
> to verify that my appenders have the expected configuration attributes. For
> example, I would like to be able to verify that my syslog appender is
> connecting to the expected host,port,protocol, etc.
>
> On Wed, Jan 27, 2016 at 3:19 PM, Mikael Ståldal  > wrote:
>
>> It would be useful if Apostolis Giannakidis can explain the use case
>> behind this request, now it is a bit abstract to me.
>>
>> On Wed, Jan 27, 2016 at 4:13 PM, Matt Sicker  wrote:
>>
>>> I mean keeping the Node tree to get attributes. It would only work from
>>> config files (and the config builder classes). We get questions every so
>>> often about modifying the config programmatically which would either need
>>> to maintain more Nodes or just be unsupported.
>>>
>>> On 27 January 2016 at 09:09, Mikael Ståldal 
>>> wrote:
>>>
>>> > I don't quite understand what you mean.
>>> >
>>> > On Wed, Jan 27, 2016 at 4:02 PM, Matt Sicker  wrote:
>>> >
>>> > > That sounds a little fragile as some people either create or modify
>>> their
>>> > > creation directly from the plugin factories.
>>> > >
>>> > > On 27 January 2016 at 07:05, Mikael Ståldal <
>>> mikael.stal...@magine.com>
>>> > > wrote:
>>> > >
>>> > > > Then perhaps we should keep the node tree and expose it for this
>>> kind
>>> > of
>>> > > > queries, something like this:
>>> > > >
>>> > > > String hostname = loggerContext.getConfiguration().
>>> > > > getAttributesForAppender("syslogAppender").get("host");
>>> > > >
>>> > > > This would require a new method in
>>> > > > org.apache.logging.log4j.core.config.Configuration:
>>> > > >
>>> > > > public Map getAttributesForAppender(String
>>> > appenderName);
>>> > > >
>>> > > >
>>> > > >
>>> > > > On Wed, Jan 27, 2016 at 1:27 PM, Ralph Goers <
>>> > ralph.go...@dslextreme.com
>>> > > >
>>> > > > wrote:
>>> > > >
>>> > > > > While I understand your point, the node tree is discarded after
>>> the
>>> > > > > plugins are created. We would have to keep it around for this to
>>> > work.
>>> > > > > Furthermore, each component would need to have a reference to its
>>> > > > > corresponding node, which we obviously don't currently do.
>>> > > > >
>>> > > > > Ralph
>>> > > > >
>>> > > > > > On Jan 27, 2016, at 2:33 AM, Mikael Ståldal <
>>> > > mikael.stal...@magine.com
>>> > > > >
>>> > > > > wrote:
>>> > > > > >
>>> > > > > > To me it does not seems good to force all Appender
>>> implementations
>>> > to
>>> > > > > > implement this. Especially not since the next logical step
>>> would
>>> > then
>>> > > > be
>>> > > > > to
>>> > > > > > do the same with other components such as Layouts. That would
>>> be a
>>> > > lot
>>> > > > of
>>> > > > > > work in total, and also add more work for all future
>>> components,
>>> > > > > including
>>> > > > > > 3rd party plugins.
>>> > > > > >
>>> > > > > > I think it makes more sense, and would be less work in total,
>>> if
>>> > the
>>> > > > > > configuration system would store and expose those attributes
>>> > without
>>> > > > > > involving the components themselves.
>>> > > > > >
>>> > > > > > On Wed, Jan 27, 2016 at 7:14 AM, Gary Gregory <
>>> > > garydgreg...@gmail

Re: Why is AsyncLogger#shutdown time not configurable?

2016-06-30 Thread Mikael Ståldal
AsyncAppender has a shutdownTimeout parameter. It would be good to have
something similar for async loggers. It is important to not block JVM
shutdown forever.

On Thu, Jun 30, 2016 at 5:56 PM, Remko Popma  wrote:

> At the time it was on purpose but now I think about it more I agree it is
> better to use some timeout.
> Not sure when I will be able to get to it. Would you mind raising a Jira
> for this so we won't forget about it?
>
> Remko
>
> On Thu, Jun 30, 2016 at 4:10 AM, David Leonhartsberger  >
> wrote:
>
> > I was just looking at the AsyncLoggerDistruptor#stop() and figured out
> that
> > the shutdown time is not configurable and it even could be blocking
> forever
> > waiting that the Disruptor backlog has been processed.
> >
> >
> > // Calling Disruptor.shutdown() will wait until all enqueued events are
> > fully processed,
> > // but this waiting happens in a busy-spin. To avoid (postpone) wasting
> > CPU,
> > // we sleep in short chunks, up to 10 seconds, waiting for the ringbuffer
> > to drain.
> > for (int i = 0; hasBacklog(temp) && i <
> MAX_DRAIN_ATTEMPTS_BEFORE_SHUTDOWN;
> > i++) {
> > try {
> > Thread.sleep(SLEEP_MILLIS_BETWEEN_DRAIN_ATTEMPTS); // give up the CPU
> for a
> > while
> > } catch (final InterruptedException e) { // ignored
> > }
> > }
> > temp.shutdown(); // busy-spins until all events currently in the
> disruptor
> > have been processed
> >
> >
> > I was wondering why the "temp.shutdown()" call does not use a
> > (configurable) timeout?
> > Was this a design decision or was it just overlooked?
> >
> > Br,
> > DavidL
> >
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Kafka appender expecting String but getting Byte?

2016-08-08 Thread Mikael Ståldal
Log4j always passes the LogEvent as a byte[] to Kafka, so using the
Kafka StringSerializer
will not work.

You should not specify *key.serializer* or *value.serializer* in the Kafka
appender config, they are automatically set to ByteArraySerializer by
Log4j. I will improve the documentation on that.

I think that *key.class.type* and *value.class.type *are Spring specific
and thus not relevant here.

On Fri, Aug 5, 2016 at 8:03 PM, Meadowlark Bradsher  wrote:

> Hello,
>
> I am attempting to use a kafka log appender. The topic is written to Kafka
> but the appender breaks during the messaging.
>
> org.apache.kafka.common.errors.SerializationException: Can't convert
> value of class [B to class 
> org.apache.kafka.common.serialization.StringSerializer
> specified in value.serializer
>
> I had seen only one SO post about this error which seems to point to
> Spring as the culprit but I am not using Spring.
>
> http://stackoverflow.com/questions/32368372/spring-
> integration-kafka-sending-a-basic-string
>
> I am running this in IntelliJ without any Spring configuration. The
> log4j2.xml file is as follows (with modification to the Kafka host).
>
> 
> 
>   
> 
>   
> 
>
>   
> localhost:9092
> java.lang.String
> java.lang.String
> org.apache.kafka.common.
> serialization.StringSerializer
> org.apache.kafka.common.
> serialization.StringSerializer
> 
>   
>   
> 
>   
> 
> 
>   
> 
> 
>   
> 
>
>
> The test I am doing is
>
>
>
> private static final Logger logger = LogManager.getRootLogger();
>
> logger.info("{\"f1\": \"value1\"}");
>
>
>
> I just downloaded the source to log4j2 to see if this will help me
> understand what is happening but perhaps this obvious to someone in this
> community?
>
>
>
> Any pointers would be very helpful and appreciated.
>
>
>
>
>
> Thanks
>
> Meadowlark Bradsher
>
>
>
>
>
>
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Log4j2 Kafka appender NullPointerException when put the related jars in tomcat lib

2016-10-17 Thread Mikael Ståldal
oducer.java:658)
> >>>>>> at org.apache.kafka.clients.producer.KafkaProducer.(
> >>>>>> KafkaProducer.java:333)
> >>>>>> at org.apache.kafka.clients.producer.KafkaProducer.(
> >>>>>> KafkaProducer.java:188)
> >>>>>> -
> >>>>>>
> >>>>>> On Thu, Aug 18, 2016 at 5:40 PM, Gary Gregory <
> garydgreg...@gmail.com <mailto:garydgreg...@gmail.com>  garydgreg...@gmail.com <mailto:garydgreg...@gmail.com>>>
> >>>>>> wrote:
> >>>>>>> Based on the stack trace, it looks like the Slf4j logger in
> KafkaProducer
> >>>>>>> is null:
> >>>>>>>
> >>>>>>>   log.info <http://log.info/> <http://log.info/ <
> http://log.info/>>("Closing the Kafka producer with timeoutMillis = {}
> >>>>>> ms.",
> >>>>>>> timeUnit.toMillis(timeout));
> >>>>>>>
> >>>>>>> It does not look like timeUnit can be null, so it must be log.
> >>>>>>>
> >>>>>>> The root problem of course if that we have an exception thrown in
> the
> >>>>>>> KafkaProducer
> >>>>>>> ctor.
> >>>>>>>
> >>>>>>> Gary
> >>>>>>>
> >>>>>>> On Thu, Aug 18, 2016 at 3:44 PM, Bill Okara  <mailto:billok...@gmail.com> <mailto:billok...@gmail.com  billok...@gmail.com>>> wrote:
> >>>>>>>
> >>>>>>>> tried again, seemed like the .out extension got filtered out by
> mail
> >>>>>>>> server...
> >>>>>>>>
> >>>>>>>> On Thu, Aug 18, 2016 at 4:41 PM, Bill Okara  <mailto:billok...@gmail.com> <mailto:billok...@gmail.com  billok...@gmail.com>>>
> >>>>>> wrote:
> >>>>>>>>> attach the catalina.out again, didn't seem to go through last
> time...
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On Thu, Aug 18, 2016 at 4:33 PM, Bill Okara  <mailto:billok...@gmail.com> <mailto:billok...@gmail.com  billok...@gmail.com>>>
> >>>>>> wrote:
> >>>>>>>>>> Hi,
> >>>>>>>>>>
> >>>>>>>>>> When trying out the log4j2 Kafka appender, it works ok if all
> the
> >>>>>>>>>> log4j2/kafka-client related jars are packaged in the webapp's
> >>>>>>>>>> WEB-INF/lib, like:
> >>>>>>>>>>
> >>>>>>>>>>> ls WEB-INF/lib/
> >>>>>>>>>> jackson-core-2.8.1.jar
> >>>>>>>>>> log4j-core-2.6.2.jar
> >>>>>>>>>> lz4-1.3.0.jar
> >>>>>>>>>> kafka-clients-0.10.0.1.jar
> >>>>>>>>>> log4j-slf4j-impl-2.6.2.jar
> >>>>>>>>>> slf4j-api-1.7.21.jar
> >>>>>>>>>> log4j-api-2.6.2.jar
> >>>>>>>>>> log4j-web-2.6.2.jar
> >>>>>>>>>> snappy-java-1.1.2.6.jar
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> But if the jars are provided in tomcat/lib (for all webapps),
> and
> >>>>>> each
> >>>>>>>>>> webapp will have its own log4j2.xml (as in attached war), then
> when
> >>>>>>>>>> launching the webapp, will encounter:
> >>>>>>>>>>
> >>>>>>>>>> -
> >>>>>>>>>> Caused by: java.lang.NullPointerException
> >>>>>>>>>>   at org.apache.kafka.clients.producer.KafkaProducer.close(
> >>>>>>>> KafkaProducer.java:658)
> >>>>>>>>>>   at org.apache.kafka.clients.
> producer.KafkaProducer.(
> >>>>>>>> KafkaProducer.java:333)
> >>>>>>>>>>   at org.apache.kafka.clients.
> producer.KafkaProducer.(
> >>>>>>>> KafkaProducer.java:188)
> >>>>>>>>>>   at org.apache.logging.log4j.core.appender.mom.kafka.
> >>>>>>>> DefaultKafkaProducerFactory.newKafkaProducer(
> >>>>>> DefaultKafkaProducerFactory.
> >>>>>>>> java:29)
> >>>>>>>>>>   at org.apache.logging.log4j.core.appender.mom.kafka.
> >>>>>>>> KafkaManager.startup(KafkaManager.java:86)
> >>>>>>>>>>   at org.apache.logging.log4j.core.appender.mom.kafka.
> >>>>>>>> KafkaAppender.start(KafkaAppender.java:96)
> >>>>>>>>>>   at org.apache.logging.log4j.core.
> >>>>>> config.AbstractConfiguration.
> >>>>>>>> start(AbstractConfiguration.java:247)
> >>>>>>>>>>   at org.apache.logging.log4j.core.LoggerContext.
> >>>>>>>> setConfiguration(LoggerContext.java:496)
> >>>>>>>>>>   at org.apache.logging.log4j.core.
> LoggerContext.reconfigure(
> >>>>>>>> LoggerContext.java:566)
> >>>>>>>>>> -
> >>>>>>>>>>
> >>>>>>>>>> (full stack trace as in attached catalina.out)
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> To reproduce the error, simply:
> >>>>>>>>>> 1) build the attached webapp, and deploy the output to
> tomcat/webapps
> >>>>>>>>>> 2) move the WEB-INF/lib/*.jar to tomcat/lib (make sure
> WEB-INF/lib is
> >>>>>>>>>> empty after move)
> >>>>>>>>>> 3) start tomcat
> >>>>>>>>>>
> >>>>>>>>>> Tested with tomcat 7.0.70
> >>>>>>>>>>
> >>>>>>>>>> Anyone encounter similar problem? or is this a bug? (log4j2 or
> >>>>>>>>>> kafka-client bug?)
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> Thanks,
> >>>>>>>>>> Bill
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> 
> -
> >>>>>>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> <mailto:log4j-user-unsubscr...@logging.apache.org>
> >>>>>>>> For additional commands, e-mail: log4j-user-help@logging.
> apache.org <mailto:log4j-user-h...@logging.apache.org>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> --
> >>>>>>> E-Mail: garydgreg...@gmail.com <mailto:garydgreg...@gmail.com> |
> ggreg...@apache.org <mailto:ggreg...@apache.org>
> >>>>>>> Java Persistence with Hibernate, Second Edition
> >>>>>>> <http://www.manning.com/bauer3/ <http://www.manning.com/bauer3/>>
> >>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/
> <http://www.manning.com/tahchiev/>>
> >>>>>>> Spring Batch in Action <http://www.manning.com/templier/ <
> http://www.manning.com/templier/>>
> >>>>>>> Blog: http://garygregory.wordpress.com <
> http://garygregory.wordpress.com/>
> >>>>>>> Home: http://garygregory.com/ <http://garygregory.com/>
> >>>>>>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/
> GaryGregory>
> >>>>>>
> >>>>>> 
> -
> >>>>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> <mailto:log4j-user-unsubscr...@logging.apache.org>
> >>>>>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> <mailto:log4j-user-h...@logging.apache.org>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>> --
> >>>>> E-Mail: garydgreg...@gmail.com <mailto:garydgreg...@gmail.com> |
> ggreg...@apache.org <mailto:ggreg...@apache.org>
> >>>>> Java Persistence with Hibernate, Second Edition
> >>>>> <http://www.manning.com/bauer3/ <http://www.manning.com/bauer3/>>
> >>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/ <
> http://www.manning.com/tahchiev/>>
> >>>>> Spring Batch in Action <http://www.manning.com/templier/ <
> http://www.manning.com/templier/>>
> >>>>> Blog: http://garygregory.wordpress.com <
> http://garygregory.wordpress.com/>
> >>>>> Home: http://garygregory.com/ <http://garygregory.com/>
> >>>>> Tweet! http://twitter.com/GaryGregory <http://twitter.com/
> GaryGregory>
> >>>> 
> >>>> -
> >>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> <mailto:log4j-user-unsubscr...@logging.apache.org> <mailto:log4j-user-
> unsubscr...@logging.apache.org <mailto:log4j-user-
> unsubscr...@logging.apache.org>>
> >>>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> <mailto:log4j-user-h...@logging.apache.org> <mailto:log4j-user-help@
> logging.apache.org <mailto:log4j-user-h...@logging.apache.org>>
> >>
> >> -
> >> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> <mailto:log4j-user-unsubscr...@logging.apache.org>
> >> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> <mailto:log4j-user-h...@logging.apache.org>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Log4j2 Kafka appender NullPointerException when put the related jars in tomcat lib

2016-10-17 Thread Mikael Ståldal
Ralph, are you going to work on this issue?

On Mon, Oct 17, 2016 at 2:04 PM, Mikael Ståldal 
wrote:

> So this issue is triggered by the fact that the Kafka client library we
> use itself does logging via SLF4J during initialization. And in this
> particular web configuration, org.slf4j.LoggerFactory.getLogger(Class)
> return null during Configuration.start().
>
> On Sat, Aug 20, 2016 at 12:13 AM, Bill Okara  wrote:
>
>> Ralph,
>>
>> thanks! created jira:
>> https://issues.apache.org/jira/browse/LOG4J2-1535
>>
>> I guess I still wanted the ClassLoaderContextSelector, as I wanted
>> each webapp to have it's own config (log to different target etc), but
>> just shared same jars. so the intention is to have all log related
>> jars in tomcat/lib, and have log4j2.xml in WEB-INF/classes.
>>
>> Another reason to have log related jars in tomcat/lib is to have some
>> common jars to log using log4j2 too...
>>
>> Thanks,
>> Bill
>>
>>
>> On Fri, Aug 19, 2016 at 3:17 PM, Ralph Goers 
>> wrote:
>> > So they are being kicked off by the webapp initialization. That follows
>> what I was thinking. I have a suspicion I may have to put in some code to
>> check if the logging classes are in the same ClassLoader as the current
>> ClassLoader. If they aren’t we probably need to kick off logging
>> initialization there first and then continue with the current
>> initialization. I need to look at the code again and try a few things
>> though.
>> >
>> > Is it possible you could create a Jira for this and attach a sample
>> project that demonstrates the problem?
>> >
>> > Another workaround to this is to not use the
>> ClassLoaderContextSelector. If you really want a common configuration
>> across all your web apps then you can use the BasicContextSelector.
>> However, that may cause problems if you try to use hot deployment.
>> >
>> > Ralph
>> >
>> >
>> >> On Aug 19, 2016, at 1:52 PM, Bill Okara  wrote:
>> >>
>> >> Hi Gary,
>> >>
>> >> actually the full stack was attached in that email already, please let
>> >> me know if you can't find them...
>> >> (Attachments: stacktrace_webinf.txt (5 kb)   stacktrace_tomcatlib.txt
>> (7 kb) )
>> >>
>> >> Yeah, that's kinda my understanding (or guess) too. That is, by
>> >> putting the log related jars in tomcat/lib, when the initializing the
>> >> log4j2.xml, it's trying to initialize the KafkaAppender, whose jars
>> >> are in tomcat/lib, thus it's trying to initialize the log4j config for
>> >> that context.
>> >>
>> >> I was able to hack/workaround the issue by adding a log4j2-test.xml in
>> >> WEB-INF/classes, and not using the KafkaAppender in the
>> >> log4j2-test.xml. In that case, when initializing for tomcat/lib, the
>> >> log4j2-test.xml got picked up before the log4j2.xml, and that kinda
>> >> avoided the problem.
>> >>
>> >> But the caveat is that no longer can use KafkaAppender for anything
>> >> logged by jars in tomcat/lib...
>> >>
>> >> I guess KafkaAppender is a special case that it's using a jar that
>> >> also uses SLF4j/log4j logs.
>> >>
>> >> By having the jars in tomcat/lib seems like pretty clean for webapps
>> >> to share same logging implementation and use their specific config.
>> >> but not sure how to better workaround / resolve the issue without
>> >> limiting all jars in tomcat/lib to not using KafkaAppender in this
>> >> case.
>> >>
>> >> comments?
>> >>
>> >>
>> >> Thanks!
>> >> Bill
>> >>
>> >>
>> >> On Fri, Aug 19, 2016 at 1:07 PM, Ralph Goers <
>> ralph.go...@dslextreme.com <mailto:ralph.go...@dslextreme.com>> wrote:
>> >>> I have a suspicion the key part of the stack trace isn’t included.  I
>> am guessing that the code that causes the first call to the Kafka appender
>> is in your web app.  This causes the ClassLoaderContextSelector to
>> initialize Log4j for the web app ClassLoader. Kafka itself is in
>> tomcat/lib. When it logs it causes Log4j to initialize for the tomcat/lib
>> ClassLoader.  That is why you see the second LoggerContext start.
>> >>>
>> >>> However, I would really like to see the stack frames just below where
>> you stopped to see what is causing the 

Re: porting log4j2 to .NET

2016-10-17 Thread Mikael Ståldal
Just to make things clear, Log4j is a logging framework for the JVM
platform, and it is agnostic to the underlying OS. It it well tested on (at
least) both Linux and Windows.

On Tue, Oct 18, 2016 at 2:33 AM, Nicholas Duane  wrote:

> Figured I would send this question out to the log4j side.  I have already
> had some email exchanges with the log4net mailing list regarding porting
> log4j2 to .NET.  My suggestion was that the apache logging framework be a
> single architecture design which is platform agnostic and then teams which
> port to the different platforms.  It seems log4net was a port of log4j and
> may be going off in its own direction from that initial port.  My viewpoint
> is that's a bad idea as one of the benefits I saw was that log4net was
> similar to log4j2 and we're looking for logging frameworks for our
> enterprise.  We have applications on both Windows/.NET and Linux/Java so
> having a logging framework for Windows/.NET which is similar to a logging
> framework for Linux/Java was a big plus.
>
>
> While I have no doubt the effort to port log4j2 to .NET is considerable,
> it would be a port and thus I'm not spending time figuring out design and
> algorithms.  Would anyone want to venture a guess at what that effort might
> be?
>
>
> Thanks,
>
> Nick
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: porting log4j2 to .NET

2016-10-18 Thread Mikael Ståldal
Maybe I am nitpicking, but Log4j is also (mostly) agnostic to what language
you run on the JVM (Java, Scala, Groovy, Clojure, etc).

I guess it would be nice to have similar logging framework for other
runtimes (such as .Net). However, I would not like to constrain Log4j to
only use features available on both JVM and .Net.

On Tue, Oct 18, 2016 at 3:53 PM, Nicholas Duane  wrote:

> I guess platform is vague.  Maybe I should have said language agnostic.
> It would be nice to have a single logging architecture/design run on C/C++,
> .NET, Java, etc.  Or at least it seems like a nice feature to me.  I would
> assume there are many enterprises out there that have applications running
> on different OS's and languages.  If I'm trying to pick a logging framework
> to use and I find a popular one which is capable and runs similarly across
> the OS's and languages then that's a big plus in my mind.
>
>
> Thanks,
>
> Nick
>
> 
> From: Mikael Ståldal 
> Sent: Tuesday, October 18, 2016 2:52 AM
> To: Log4J Users List
> Subject: Re: porting log4j2 to .NET
>
> Just to make things clear, Log4j is a logging framework for the JVM
> platform, and it is agnostic to the underlying OS. It it well tested on (at
> least) both Linux and Windows.
>
> On Tue, Oct 18, 2016 at 2:33 AM, Nicholas Duane  wrote:
>
> > Figured I would send this question out to the log4j side.  I have already
> > had some email exchanges with the log4net mailing list regarding porting
> > log4j2 to .NET.  My suggestion was that the apache logging framework be a
> > single architecture design which is platform agnostic and then teams
> which
> > port to the different platforms.  It seems log4net was a port of log4j
> and
> > may be going off in its own direction from that initial port.  My
> viewpoint
> > is that's a bad idea as one of the benefits I saw was that log4net was
> > similar to log4j2 and we're looking for logging frameworks for our
> > enterprise.  We have applications on both Windows/.NET and Linux/Java so
> > having a logging framework for Windows/.NET which is similar to a logging
> > framework for Linux/Java was a big plus.
> >
> >
> > While I have no doubt the effort to port log4j2 to .NET is considerable,
> > it would be a port and thus I'm not spending time figuring out design and
> > algorithms.  Would anyone want to venture a guess at what that effort
> might
> > be?
> >
> >
> > Thanks,
> >
> > Nick
> >
>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.stal...@magine.com
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com<
> http://www.magine.com>
> [https://de.magine.com/content/uploads/2016/09/magine_global_social.png]<
> http://www.magine.com/>
>
> TV online with Magine TV<http://www.magine.com/>
> www.magine.com
> Watch the TV you love, on any device, anywhere in Germany and Sweden and
> find out more about our global OTT B2B solutions. Get started today.
>
>
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: porting log4j2 to .NET

2016-10-18 Thread Mikael Ståldal
...or a standardized non-binary format (like GELF, JSON based).

On Tue, Oct 18, 2016 at 3:58 PM, Matt Sicker  wrote:

> Using syslog is a pretty standard way to collect logs from all sorts of
> programs and goes back decades. There has been an update to the syslog
> format in RFC 5424 which fleshes it out a bunch.
>
> Then there are programs like Logstash and Flume which can be used in a more
> platform-agnostic manner to collect logs from different applications.
>
> Really, when it comes down to it, the most standard way you can log
> everything regardless of programming language is to use log files or some
> sort of network appender using a standardized binary format.
>
> On 18 October 2016 at 08:53, Nicholas Duane  wrote:
>
> > I guess platform is vague.  Maybe I should have said language agnostic.
> > It would be nice to have a single logging architecture/design run on
> C/C++,
> > .NET, Java, etc.  Or at least it seems like a nice feature to me.  I
> would
> > assume there are many enterprises out there that have applications
> running
> > on different OS's and languages.  If I'm trying to pick a logging
> framework
> > to use and I find a popular one which is capable and runs similarly
> across
> > the OS's and languages then that's a big plus in my mind.
> >
> >
> > Thanks,
> >
> > Nick
> >
> > 
> > From: Mikael Ståldal 
> > Sent: Tuesday, October 18, 2016 2:52 AM
> > To: Log4J Users List
> > Subject: Re: porting log4j2 to .NET
> >
> > Just to make things clear, Log4j is a logging framework for the JVM
> > platform, and it is agnostic to the underlying OS. It it well tested on
> (at
> > least) both Linux and Windows.
> >
> > On Tue, Oct 18, 2016 at 2:33 AM, Nicholas Duane  wrote:
> >
> > > Figured I would send this question out to the log4j side.  I have
> already
> > > had some email exchanges with the log4net mailing list regarding
> porting
> > > log4j2 to .NET.  My suggestion was that the apache logging framework
> be a
> > > single architecture design which is platform agnostic and then teams
> > which
> > > port to the different platforms.  It seems log4net was a port of log4j
> > and
> > > may be going off in its own direction from that initial port.  My
> > viewpoint
> > > is that's a bad idea as one of the benefits I saw was that log4net was
> > > similar to log4j2 and we're looking for logging frameworks for our
> > > enterprise.  We have applications on both Windows/.NET and Linux/Java
> so
> > > having a logging framework for Windows/.NET which is similar to a
> logging
> > > framework for Linux/Java was a big plus.
> > >
> > >
> > > While I have no doubt the effort to port log4j2 to .NET is
> considerable,
> > > it would be a port and thus I'm not spending time figuring out design
> and
> > > algorithms.  Would anyone want to venture a guess at what that effort
> > might
> > > be?
> > >
> > >
> > > Thanks,
> > >
> > > Nick
> > >
> >
> >
> >
> > --
> > [image: MagineTV]
> >
> > *Mikael Ståldal*
> > Senior software developer
> >
> > *Magine TV*
> > mikael.stal...@magine.com
> > Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com<
> > http://www.magine.com>
> > [https://de.magine.com/content/uploads/2016/09/magine_global_social.png
> ]<
> > http://www.magine.com/>
> >
> > TV online with Magine TV<http://www.magine.com/>
> > www.magine.com
> > Watch the TV you love, on any device, anywhere in Germany and Sweden and
> > find out more about our global OTT B2B solutions. Get started today.
> >
> >
> >
> > Privileged and/or Confidential Information may be contained in this
> > message. If you are not the addressee indicated in this message
> > (or responsible for delivery of the message to such a person), you may
> not
> > copy or deliver this message to anyone. In such case,
> > you should destroy this message and kindly notify the sender by reply
> > email.
> >
>
>
>
> --
> Matt Sicker 
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: porting log4j2 to .NET

2016-10-18 Thread Mikael Ståldal
In my opinion, one of the major benefits of Log4j is its comprehensive
ecosystem of plugins (appenders, layouts, etc), both bundled and 3rd party.
This will automatically benefit all users of Log4j, regardless of language
(on the JVM) and OS (that you can run the JVM on). But this does not extend
to other runtimes (e.g. .Net).

Another benefit is that your application and 3rd party frameworks/libraries
you use can log via the same framework and you can collect the logs
together. This does not extend to other runtimes either, since you won't
use the same libraries.

On Tue, Oct 18, 2016 at 5:03 PM, Matt Sicker  wrote:

> I'm saying the architecture of the code depends on the language you're
> using. Different design patterns apply to different languages, for
> instance. A logging framework in Java and C# might be very similar, but
> they'd look quite different from one written entirely in Clojure or F#. The
> general concept of appenders, loggers, filters, etc., would all probably
> apply, but the APIs would probably differ a lot. This would affect plugin
> authors more than users of the library, but the only common things I could
> see happening between different languages might be a similar API in a
> Logger class or module.
>
> On 18 October 2016 at 09:45, Nicholas Duane  wrote:
>
> > I just mentioned the config as one piece where I think it would be very
> > useful to have similar, if not exactly the same, configs across
> > implementations.  I also realize that it might not be possible.
> >
> >
> > So are you saying that when you get to designing a logging framework you
> > first have to know what language/runtime you're designing it for?  I
> would
> > think not.  Hopefully most, if not all, can be designed OS/runtime
> agnostic
> > and without having to design to a lowest common denominator.
> >
> >
> > Also not sure about the OOP thing.  As far as I can tell, OOP is just a
> > convenience thing, syntactic sugar.  I believe you can do the same in a
> > procedural language.
> >
> >
> > Thanks,
> >
> > Nick
> >
> > 
> > From: Matt Sicker 
> > Sent: Tuesday, October 18, 2016 10:37 AM
> > To: Log4J Users List
> > Subject: Re: porting log4j2 to .NET
> >
> > Every programming language has its own idioms, and that even goes for all
> > the various JVM languages as demonstrated by the log4j-scala API. Unless
> > you mean more of an architectural thing with a similar config format,
> then
> > that might be more possible, but even that relies on a language being
> > mostly OOP or mostly procedural or mostly functional or some other exotic
> > thing.
> >
> > On 18 October 2016 at 09:23, Nicholas Duane  wrote:
> >
> > > I agree.  I'm also one for not coding to the lowest common denominator.
> > > That's one reason we're not using a logging facade as I assume with a
> > > facade you get only the features that are common across the set of
> > logging
> > > frameworks the facade supports.
> > >
> > >
> > > What I'm suggesting is to come up with a design and architecture which
> is
> > > language/runtime/OS agnostic.  While it's easy for me to say that I
> > > wouldn't be surprised if it's more difficult to achieve.  When it comes
> > to
> > > implementation I would assume the features might manifest themselves in
> > > different ways across the different languages/runtimes/OS's.  For
> > instance,
> > > .NET has extension methods and Java doesn't.  You might decide to
> > implement
> > > some features in .NET using extension methods and in Java you'll have
> to
> > > pick a different way to implement.  Configuration might be another area
> > > where there are differences among the different runtimes and thus the
> > > implementation might be a bit different.  Maybe there's even a feature
> > that
> > > one implementation has that others don't just because there is no way,
> or
> > > no easy enough way to implement.
> > >
> > >
> > > Thanks,
> > >
> > > Nick
> > >
> > > 
> > > From: Mikael Ståldal 
> > > Sent: Tuesday, October 18, 2016 10:04 AM
> > > To: Log4J Users List
> > > Subject: Re: porting log4j2 to .NET
> > >
> > > Maybe I am nitpicking, but Log4j is also (mostly) agnostic to what
> > language
> > > you run on the JVM (Java, Scala, Groovy, Clojure, etc).
> > >
> > >

Re: porting log4j2 to .NET

2016-10-19 Thread Mikael Ståldal
e's some stuff I'm missing.  Still not sure why most of
> the design for this has to know what runtime/language it's targeting.
> >>
> >>
> >> Thanks,
> >>
> >> Nick
> >>
> >> 
> >> From: Matt Sicker mailto:boa...@gmail.com>  boa...@gmail.com <mailto:boa...@gmail.com>>>
> >> Sent: Tuesday, October 18, 2016 12:22 PM
> >> To: Log4J Users List
> >> Subject: Re: porting log4j2 to .NET
> >>
> >> Really, the only portable-ish way to make a common framework would be to
> >> write them in C or Rust or something and make glue code for every
> runtime
> >> out there. JVM users tend to prefer Java-native libraries over
> >> JNI/JNA/whatever type libraries, and I'm sure that's not uncommon in
> some
> >> other runtimes.
> >>
> >> On 18 October 2016 at 10:11, Mikael Ståldal  <mailto:mikael.stal...@magine.com>>
> >> wrote:
> >>
> >>> In my opinion, one of the major benefits of Log4j is its comprehensive
> >>> ecosystem of plugins (appenders, layouts, etc), both bundled and 3rd
> party.
> >>> This will automatically benefit all users of Log4j, regardless of
> language
> >>> (on the JVM) and OS (that you can run the JVM on). But this does not
> extend
> >>> to other runtimes (e.g. .Net).
> >>>
> >>> Another benefit is that your application and 3rd party
> frameworks/libraries
> >>> you use can log via the same framework and you can collect the logs
> >>> together. This does not extend to other runtimes either, since you
> won't
> >>> use the same libraries.
> >>>
> >>> On Tue, Oct 18, 2016 at 5:03 PM, Matt Sicker  <mailto:boa...@gmail.com>> wrote:
> >>>
> >>>> I'm saying the architecture of the code depends on the language you're
> >>>> using. Different design patterns apply to different languages, for
> >>>> instance. A logging framework in Java and C# might be very similar,
> but
> >>>> they'd look quite different from one written entirely in Clojure or
> F#.
> >>> The
> >>>> general concept of appenders, loggers, filters, etc., would all
> probably
> >>>> apply, but the APIs would probably differ a lot. This would affect
> plugin
> >>>> authors more than users of the library, but the only common things I
> >>> could
> >>>> see happening between different languages might be a similar API in a
> >>>> Logger class or module.
> >>>>
> >>>> On 18 October 2016 at 09:45, Nicholas Duane  nic...@msn.com>> wrote:
> >>>>
> >>>>> I just mentioned the config as one piece where I think it would be
> very
> >>>>> useful to have similar, if not exactly the same, configs across
> >>>>> implementations.  I also realize that it might not be possible.
> >>>>>
> >>>>>
> >>>>> So are you saying that when you get to designing a logging framework
> >>> you
> >>>>> first have to know what language/runtime you're designing it for?  I
> >>>> would
> >>>>> think not.  Hopefully most, if not all, can be designed OS/runtime
> >>>> agnostic
> >>>>> and without having to design to a lowest common denominator.
> >>>>>
> >>>>>
> >>>>> Also not sure about the OOP thing.  As far as I can tell, OOP is
> just a
> >>>>> convenience thing, syntactic sugar.  I believe you can do the same
> in a
> >>>>> procedural language.
> >>>>>
> >>>>>
> >>>>> Thanks,
> >>>>>
> >>>>> Nick
> >>>>>
> >>>>> 
> >>>>> From: Matt Sicker mailto:boa...@gmail.com>>
> >>>>> Sent: Tuesday, October 18, 2016 10:37 AM
> >>>>> To: Log4J Users List
> >>>>> Subject: Re: porting log4j2 to .NET
> >>>>>
> >>>>> Every programming language has its own idioms, and that even goes for
> >>> all
> >>>>> the various JVM languages as demonstrated by the log4j-scala API.
> >>> Unless
> >>>>> you mean more of an architectural thing with a similar config format,
> >>>> then

Re: Editable File Log File Permissions

2016-11-14 Thread Mikael Ståldal
gt; > > > matching
> > > > > > > > > >> > requirements
> > > > > > > > > >> > > recently. All I could find was something dated in
> > 2006:
> > > > > > > > > >> > > https://bz.apache.org/
> bugzilla/show_bug.cgi?id=40407
> > > > > > > > > >> > >
> > > > > > > > > >> > > Thank you.
> > > > > > > > > >> > >
> > > > > > > > > >> >
> > > > > > > > > >>
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > E-Mail: garydgreg...@gmail.com   |
> > > ggreg...@apache.org 
> > > > > 
> > > > > > > Java Persistence with Hibernate, Second Edition
> > > > > > > <https://www.amazon.com/gp/product/1617290459/ref=as_li_
> > > > > > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&
> > > > > > > linkCode=as2&tag=garygregory-20&linkId=
> > > > cadb800f39946ec62ea2b1af9fe6a2
> > > > > b8>
> > > > > > >
> > > > > > > <http:ir-na.amazon-adsystem.com/e/ir?t=
> > > > garygregory-20&l=am2&o=1&a=
> > > > > > > 1617290459>
> > > > > > > JUnit in Action, Second Edition
> > > > > > > <https://www.amazon.com/gp/product/1935182021/ref=as_li_
> > > > > > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&
> > > > > > > linkCode=as2&tag=garygregory-20&linkId=
> > > > 31ecd1f6b6d1eaf8886ac902a24de4
> > > > > > 18%22
> > > > > > > >
> > > > > > >
> > > > > > > <http:ir-na.amazon-adsystem.com/e/ir?t=
> > > > garygregory-20&l=am2&o=1&a=
> > > > > > > 1935182021>
> > > > > > > Spring Batch in Action
> > > > > > > <https://www.amazon.com/gp/product/1935182951/ref=as_li_
> > > > > > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&
> > > > > > > linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%
> > > > > > > 7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
> > > > > > > <http:ir-na.amazon-adsystem.com/e/ir?t=
> > > > garygregory-20&l=am2&o=1&a=
> > > > > > > 1935182951>
> > > > > > > Blog: http://garygregory.wordpress.com
> > > > > > > Home: http://garygregory.com/
> > > > > > > Tweet! http://twitter.com/GaryGregory
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > E-Mail: garydgreg...@gmail.com   |
> > > ggreg...@apache.org 
> > > > > 
> > > > > Java Persistence with Hibernate, Second Edition
> > > > > <https://www.amazon.com/gp/product/1617290459/ref=as_li_
> > > > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&
> > > > > linkCode=as2&tag=garygregory-20&linkId=
> > cadb800f39946ec62ea2b1af9fe6a2
> > > b8>
> > > > >
> > > > > <http:ir-na.amazon-adsystem.com/e/ir?t=
> > garygregory-20&l=am2&o=1&a=
> > > > > 1617290459>
> > > > > JUnit in Action, Second Edition
> > > > > <https://www.amazon.com/gp/product/1935182021/ref=as_li_
> > > > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&
> > > > > linkCode=as2&tag=garygregory-20&linkId=
> > 31ecd1f6b6d1eaf8886ac902a24de4
> > > > 18%22
> > > > > >
> > > > >
> > > > > <http:ir-na.amazon-adsystem.com/e/ir?t=
> > garygregory-20&l=am2&o=1&a=
> > > > > 1935182021>
> > > > > Spring Batch in Action
> > > > > <https://www.amazon.com/gp/product/1935182951/ref=as_li_
> > > > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&
> > > > > linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%
> > > > > 7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
> > > > > <http:ir-na.amazon-adsystem.com/e/ir?t=
> > garygregory-20&l=am2&o=1&a=
> > > > > 1935182951>
> > > > > Blog: http://garygregory.wordpress.com
> > > > > Home: http://garygregory.com/
> > > > > Tweet! http://twitter.com/GaryGregory
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > E-Mail: garydgreg...@gmail.com  | ggreg...@apache.org
> > > 
> > > Java Persistence with Hibernate, Second Edition
> > > <https://www.amazon.com/gp/product/1617290459/ref=as_li_
> > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&
> > > linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2
> b8>
> > >
> > > <http:ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> > > 1617290459>
> > > JUnit in Action, Second Edition
> > > <https://www.amazon.com/gp/product/1935182021/ref=as_li_
> > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&
> > > linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de4
> > 18%22
> > > >
> > >
> > > <http:ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> > > 1935182021>
> > > Spring Batch in Action
> > > <https://www.amazon.com/gp/product/1935182951/ref=as_li_
> > > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&
> > > linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%
> > > 7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
> > > <http:ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> > > 1935182951>
> > > Blog: http://garygregory.wordpress.com
> > > Home: http://garygregory.com/
> > > Tweet! http://twitter.com/GaryGregory
> > >
> >
>
>
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition
> <https://www.amazon.com/gp/product/1617290459/ref=as_li_
> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&
> linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>
>
> <http:ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> 1617290459>
> JUnit in Action, Second Edition
> <https://www.amazon.com/gp/product/1935182021/ref=as_li_
> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&
> linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22
> >
>
> <http:ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> 1935182021>
> Spring Batch in Action
> <https://www.amazon.com/gp/product/1935182951/ref=as_li_
> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&
> linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%
> 7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
> <http:ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> 1935182951>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Copying appenders and loggers from a confgiruation to a builder

2016-11-17 Thread Mikael Ståldal
ConfigurationBuilder.writeXmlConfiguration(OutputStream) only works if you
have an ConfigurationBuilder that is populated somehow, you cannot use it
on an arbitrary Configuration object. I tried to support that, but it
turned out to be to difficult.

The built-in parsers for XML, JSON and YAML configurations are not
based on ConfigurationBuilder
(XML and JSON configuration parsers are older than ConfigurationBuilder,
and YAML configuration parser is based on the JSON configuration parser).

The properties configuration parser is newer and based on ConfigurationBuilder.
(But I guess that will not help you.)

Parsing an XML config file, transfer it to an ConfigurationBuilder and
write out to another XML config file will not be easy since the XML config
parser discards some information that is needed to reconstruct the config
file.

On Thu, Nov 17, 2016 at 4:33 PM, Matt Sicker  wrote:

> I don't believe there is an API in ConfigurationBuilder that uses actual
> plugin objects. That would certainly be a new feature. However, you did
> mention combining configuration files which is already implemented through
> composite configuration:
> http://logging.apache.org/log4j/2.x/manual/configuration.html#
> CompositeConfiguration
>
> On 17 November 2016 at 09:29, COHEN, STEVEN M  wrote:
>
> > I am trying to construct a program that basically reads a bunch of log4j2
> > configuration files and combines them into one, writing this back to disk
> > using the new ConfigurationBuilder.writeXmlConfiguration(OutputStream)
> > method.
> >
> > But I run up against what seems to me to be a gap in the API unless I am
> > missing something:
> > Having created a ConfigurationBuilder for the destination file and having
> > read one of the to-be-combined configuration files into a Configuration
> > object, there appears to be nothing in the ConfigurationBuilder interface
> > that would allow, say, one of the appenders from the read-in
> configuration
> > to be copied, as a whole object,into the builder, short of deconstructing
> > it down to its constituent elements and adding them one by one.
> >
> > Is there a way to copy an appender from one configuration to another
> > without drilling down into all its constituent parts?  And similarly, a
> way
> > to copy a logger from one configuration to another without drilling down
> to
> > its constituent parts?  Or must I write all this code myself?
> >
> >
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
>
>
> --
> Matt Sicker 
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: log4j2 - Logger does not have the configuration If procured before LoggerContext has initialized

2016-11-30 Thread Mikael Ståldal
Any particular reason for not using a configuration file?

On Wed, Nov 30, 2016 at 5:31 AM, Tarun Sharma 
wrote:

> Hi,
>
>
>
> While upgrading from 1.2.17 to 2.5, I have come across a major
> difference.  Please see following code snippets.
>
>
>
> Log4j1.2.17
>
> private  static final Logger LOGGER = Logger.getLogger(TestLog.class);
>
> public static void main(String args[])
> {
> Properties p = new Properties();
> p.setProperty("log4j.debug","true");
> p.setProperty("log4j.rootLogger","info,cfg");
> p.setProperty("log4j.appender.cfg","org.apache.log4j.
> ConsoleAppender");
> p.setProperty("log4j.appender.cfg.layout","org.apache.log4j.
> PatternLayout");
> PropertyConfigurator.configure(p);
> LOGGER.info("INFO"); //logs on console
> LOGGER.warn("warn");  //logs on console
> LOGGER.error("error");  //logs on console
> }
>
>
>
> Log4j2 v2.5
>
>
>
> private static final Logger LOGGER = LogManager.getLogger(TestLog.class);
>
> public static void main(String[] args)
> {
> PropertiesConfigurationFactory factory = new
> PropertiesConfigurationFactory();   // This line and the try catch below
> replace the
> Properties cfg = new Properties();
> cfg.setProperty("name", "config");
> cfg.setProperty("status", "debug");
> cfg.setProperty("appenders","console");
> cfg.setProperty("appender.console.type","Console");
> cfg.setProperty("appender.console.name","Console");
> cfg.setProperty("appender.console.layout.type","PatternLayout");
> cfg.setProperty("rootLogger.level","info");
> cfg.setProperty("rootLogger.appenderRefs","console");
> cfg.setProperty("rootLogger.appenderRef.console.ref","Console");
> try {
> ConfigurationSource configSrc = createConfigurationSource(cfg);
>   //PropertyConfigurator.configure(cfg); from log4j1.2
>
> Configuration conf = factory.getConfiguration(configSrc);
> System.setProperty("Log4jContextSelector",
> "org.apache.logging.log4j.core.selector.BasicContextSelector");
> LoggerContext ctx = Configurator.initialize(conf);
> ContextAnchor.THREAD_CONTEXT.set(ctx);
> }
> catch (IOException io)
> {
>
> }
>
> LOGGER.info("INFO");  // does not print
> LOGGER.warn("warn");// does not print
> LOGGER.error("error");  //prints to console
> }
>
> private static ConfigurationSource createConfigurationSource(Properties
> cfg) throws IOException {
>
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> cfg.store(out, null);
> InputStream in = new ByteArrayInputStream(out.toByteArray());
> return new ConfigurationSource(in);
> }
> }
>
>
>
>
>
> So, In log4j2 , the Logger which is initialized as private static final,
> is not aware of the configurations, but in logj1.x, It is.
>
>
>
> Is there any way to make log4j2 code behave as log4j1.x did?
>
>
>
> Best Regards,
>
> Tarun
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Asynchronous Compression and JVM Shutdown

2017-01-23 Thread Mikael Ståldal
The problem with Log4j 2.7 is that it uses a pool of non-daemon threads for
the RollingFileManager tasks. This will needlessly block application
shutdown when the application exit by returning from the main method (and
not use System.exit()). If you use System.exit(), you will not experience
this problem.

However, if you use System.exit(), you might instead abort a background
task that happens to be in progress.

On Sun, Jan 22, 2017 at 10:16 PM, Robert Schmidtke 
wrote:

> Hi Ralph, thanks for your reply. I'm using Log4j2 version 2.7. Which
> behavior does this version have? Shutdown completes in a reasonable amount
> of time, yet the compression action thread cannot finish. Is there a
> version that does wait for the threads? Is there anything I can do to help
> on this issue? Thanks for working on it, looking forward to a fix for that.
>
> Robert
>
> On Sun, Jan 22, 2017 at 10:07 PM, Apache 
> wrote:
>
> > It is actually interesting that you mention that as I am working on that
> > code right now.
> >
> > This is a bit of code that has been troublesome for us and the behavior
> > depends on which version of Log4j you are using.  Log4j used to spawn a
> > thread to do the compression and the thread did not always complete
> before
> > shutdown. In 2.7 the code modified to use an ExecutorService. However,
> this
> > had the implementation of that had the undesirable side effect that it
> > caused shutdown to wait for a long period of time for no good reason, so
> > that code was just recently reverted.  Since our unit tests now regularly
> > fail again because the test app is completing before the compression
> action
> > completes I am now looking at this again to find a better solution that
> > will wait for the compression action to complete, but not cause shutdown
> to
> > be delayed when there is nothing to do.
> >
> > Ralph
> >
> > > On Jan 22, 2017, at 1:06 PM, Robert Schmidtke 
> > wrote:
> > >
> > > Hi everyone,
> > >
> > > I am currently debugging an issue, and I would like to know how an
> > > asynchronous compression action that is currently running in a thread
> > > created through the rolling file manager (
> > > https://github.com/apache/logging-log4j2/blob/master/
> > log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/
> > RollingFileManager.java#L326)
> > > reacts to JVM shutdown. I could not find any code that would block
> until
> > > the action is done during shutdown.
> > >
> > > Some background to the problem: I'm creating large log files in a Spark
> > on
> > > Yarn application, and I roll over at a size of 4GB, using gz. When
> > > analyzing the log files, I see that I get log.1.gz, log.2.gz (just like
> > the
> > > pattern I defined) but also log.5 and log.5.gz. The log.5.gz archive is
> > not
> > > readable, so I'm guessing that the compression action could not finish
> > its
> > > work, because the JVM it is running in was shut down by Yarn too
> early. I
> > > suspected that calling LogManager.shutdown(); would block until all
> > threads
> > > are done, but it does not seem to be the case.
> > >
> > > What am I missing here? What needs to be the appropriate setup for
> having
> > > Log4j2 finish its compression actions before its JVM is shut down? Many
> > > thanks in advance!
> > >
> > > Robert
> > >
> > > --
> > > My GPG Key ID: 336E2680
> >
> >
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
>
>
> --
> My GPG Key ID: 336E2680
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Marker and filter

2017-02-08 Thread Mikael Ståldal
How do I configure Log4j to let through log events that (has level WARN or
higher OR (has level INFO AND has a specific marker set))?

Log events with level INFO without the marker should not be passed through.

-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Marker and filter

2017-02-08 Thread Mikael Ståldal
I figured out:









On Wed, Feb 8, 2017 at 12:28 PM, Mikael Ståldal 
wrote:

> How do I configure Log4j to let through log events that (has level WARN or
> higher OR (has level INFO AND has a specific marker set))?
>
> Log events with level INFO without the marker should not be passed through.
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.stal...@magine.com
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Broken downloads

2017-02-13 Thread Mikael Ståldal
The .zip and .tar.gz links on
https://logging.apache.org/log4j/2.x/download.html actually goes to another
HTML pages with the actual download links on.

Maybe the URLs to the mirrors page should not have .zip or .tar.gz
extension to avoid confusion?

On Mon, Feb 13, 2017 at 11:39 AM, Aron  wrote:

> I've retried it with https://www.apache.org/dyn/clo
> ser.lua/logging/log4j/2.8/apache-log4j-2.8-bin.zip and I'm still getting
> an error.
> Any ideas ? (Linux-Laptop also, so it's not antivirus related).
>
> Aron
>
> I was just able to successfully download and explode the src and bin zip
>> and tar.gz files.
>>
>> Ralph
>>
>> On Feb 12, 2017, at 1:30 PM, Aron  wrote:
>>>
>>> Hello,
>>> the current .zip & .tar.gz Downloads for 2.8 binaries are broken, as
>>> they're reported as invalid from 7zip and windows.
>>> Has anyone else experienced this problem ?
>>> The same problem occurs on my linux box.
>>>
>>> Regards Aron
>>>
>>>
>>> -
>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>>>
>>>
>>>
>>
>> -
>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>>
>>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: log4j2 issue

2017-03-17 Thread Mikael Ståldal
Have you tried to set blocking="false" on the AsyncAppender you have around
KafkaAppender?

Have you tried using the system properties log4j2.AsyncQueueFullPolicy and
log4j2.DiscardThreshold?
https://logging.apache.org/log4j/2.x/manual/configuration.html#log4j2.AsyncQueueFullPolicy

On Tue, Mar 14, 2017 at 1:00 PM, Yang Rui  wrote:

> Hi,
>
> I am Rui from China.
>
> We use both of KafkaAppender (with a AsyncAppender wrapper)
> and FileAppender of log4j2 with version 2.6.2 in the application.
>
> Here is the scenaria, when kafka cluster down and stop
> service, the application will slow down and wait for given timeout (
> request.timeout.ms)
>
> to response finally (The bufferSize of AsyncKafka is reached).
>
> I am wondering if there is any solution that the
> fileAppender can always work normally without any performance issue which
> affected
>
> by KafkaAppender. In other words, the KafkaAppender can "
> DISCARD" the logs when kafka cluster down while the application
>
> can output the logs by FileAppender.
>
>
> Thanks,
> Rui
>
>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Kafka Appender with Programmatic Configuration

2017-03-29 Thread Mikael Ståldal
Have you tried this:

kafkaBuilder.addComponent(builder.newComponent("bootstrap.servers",
"Property", "kafka.host:*9092*"));


On Wed, Mar 29, 2017 at 5:26 PM, Matt Sicker  wrote:

> Looks like a bug to me! Here's the issue: a Properties component is
> injected into a kafka appender, but there is no way to create a Property or
> Properties component directly via the configuration builder API. The top
> level properties aren't injected in the kafka appender (and manager), so
> they're unused.
>
> Interestingly enough, I don't see a way to inject KeyValuePair components
> either (which is a similar plugin class in log4j-core).
>
> Could you make an issue here: https://issues.apache.org/jira/browse/LOG4J2
>
> On 29 March 2017 at 09:27, Marvin Geitner  wrote:
>
> > Hi all,
> >
> > I'm trying to configure the Kafka Appender with the programmatic
> > configuration described in the manuals. So I created the
> > ConfigurationFactory and set up the AppenderComponentBuilder.
> >
> > If I execute the Application I'll get following exception:
> >
> > Caused by: org.apache.kafka.common.config.ConfigException: Missing
> > required configuration "bootstrap.servers" which has no default value.
> >
> > Obviously the property "bootstrap.servers" hasn't been set.
> >
> > A builder.addProperty("bootstrap.servers", "kafka.host"); doesn't work.
> > In XML the configuration looks like 
> > kafka.host.
> >
> > But how do I set this in java?
> >
> > The code looks like the following:
> >
> > static Configuration createConfiguration(final String name,
> > ConfigurationBuilder builder) {
> >
> > builder.setConfigurationName(name);
> > builder.setStatusLevel(Level.INFO);
> >
> > AppenderComponentBuilder kafkaBuilder = builder.newAppender("
> KafkaLogger
> > ", "Kafka")
> > .addAttribute("topic", "testTopic");
> > kafkaBuilder.add(builder.newLayout("PatternLayout")
> > .addAttribute("pattern", "%d{HH:mm:ss:SSS} | %logger{20}
> |
> > %msg%n%ex{5}"));
> >
> > builder.add(kafkaBuilder);
> >
> > builder.add(builder.newRootLogger(Level.INFO).add(
> > builder.newAppenderRef("KafkaLogger")));
> >
> > return builder.build();
> > }
> >
> > Hope someone can help me.
> >
> > Thanks and BR,
> > Marvin
> >
>
>
>
> --
> Matt Sicker 
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Kafka Appender with Programmatic Configuration

2017-03-29 Thread Mikael Ståldal
But it would be nice to have a simpler way to do that.

On Wed, Mar 29, 2017 at 5:28 PM, Mikael Ståldal 
wrote:

> Have you tried this:
>
> kafkaBuilder.addComponent(builder.newComponent("bootstrap.servers", 
> "Property", "kafka.host:*9092*"));
>
>
> On Wed, Mar 29, 2017 at 5:26 PM, Matt Sicker  wrote:
>
>> Looks like a bug to me! Here's the issue: a Properties component is
>> injected into a kafka appender, but there is no way to create a Property
>> or
>> Properties component directly via the configuration builder API. The top
>> level properties aren't injected in the kafka appender (and manager), so
>> they're unused.
>>
>> Interestingly enough, I don't see a way to inject KeyValuePair components
>> either (which is a similar plugin class in log4j-core).
>>
>> Could you make an issue here: https://issues.apache.org/jira
>> /browse/LOG4J2
>>
>> On 29 March 2017 at 09:27, Marvin Geitner  wrote:
>>
>> > Hi all,
>> >
>> > I'm trying to configure the Kafka Appender with the programmatic
>> > configuration described in the manuals. So I created the
>> > ConfigurationFactory and set up the AppenderComponentBuilder.
>> >
>> > If I execute the Application I'll get following exception:
>> >
>> > Caused by: org.apache.kafka.common.config.ConfigException: Missing
>> > required configuration "bootstrap.servers" which has no default value.
>> >
>> > Obviously the property "bootstrap.servers" hasn't been set.
>> >
>> > A builder.addProperty("bootstrap.servers", "kafka.host"); doesn't work.
>> > In XML the configuration looks like 
>> > kafka.host.
>> >
>> > But how do I set this in java?
>> >
>> > The code looks like the following:
>> >
>> > static Configuration createConfiguration(final String name,
>> > ConfigurationBuilder builder) {
>> >
>> > builder.setConfigurationName(name);
>> > builder.setStatusLevel(Level.INFO);
>> >
>> > AppenderComponentBuilder kafkaBuilder =
>> builder.newAppender("KafkaLogger
>> > ", "Kafka")
>> > .addAttribute("topic", "testTopic");
>> > kafkaBuilder.add(builder.newLayout("PatternLayout")
>> > .addAttribute("pattern", "%d{HH:mm:ss:SSS} |
>> %logger{20} |
>> > %msg%n%ex{5}"));
>> >
>> > builder.add(kafkaBuilder);
>> >
>> > builder.add(builder.newRootLogger(Level.INFO).add(
>> > builder.newAppenderRef("KafkaLogger")));
>> >
>> > return builder.build();
>> > }
>> >
>> > Hope someone can help me.
>> >
>> > Thanks and BR,
>> > Marvin
>> >
>>
>>
>>
>> --
>> Matt Sicker 
>>
>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.stal...@magine.com
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Kafka Appender with Programmatic Configuration

2017-03-30 Thread Mikael Ståldal
Would it make sense to have shortcuts for Property and KeyValuePair, since
they are generic and used by several appenders/layouts?

On Wed, Mar 29, 2017 at 7:12 PM, Matt Sicker  wrote:

> Oh, I see. That's an interesting API...
>
> On 29 March 2017 at 10:49, Marvin Geitner  wrote:
>
> > Thank you very much,
> >
> > kafkaBuilder.addComponent(builder.newComponent("bootstrap.servers",
> > "Property", "kafka.host:*9092*"));
> >
> > is working.
> >
> > BR
> > Marvin
> >
> > -Ursprüngliche Nachricht-
> > Von: Ralph Goers [mailto:ralph.go...@dslextreme.com]
> > Gesendet: Mittwoch, 29. März 2017 17:46
> > An: Log4J Users List 
> > Betreff: Re: Kafka Appender with Programmatic Configuration
> >
> > Mikael’s solution is correct. Every item in the ConfigurationBuilder is a
> > Component. We have “special” Components for things that are always used,
> > such as Loggers and Appenders. But we can’t know about every type of
> > Component so in those cases you just use the generic Component.
> >
> > Ralph
> >
> > > On Mar 29, 2017, at 8:26 AM, Matt Sicker  wrote:
> > >
> > > Looks like a bug to me! Here's the issue: a Properties component is
> > > injected into a kafka appender, but there is no way to create a
> > > Property or Properties component directly via the configuration
> > > builder API. The top level properties aren't injected in the kafka
> > > appender (and manager), so they're unused.
> > >
> > > Interestingly enough, I don't see a way to inject KeyValuePair
> > > components either (which is a similar plugin class in log4j-core).
> > >
> > > Could you make an issue here:
> > > https://issues.apache.org/jira/browse/LOG4J2
> > >
> > > On 29 March 2017 at 09:27, Marvin Geitner 
> wrote:
> > >
> > >> Hi all,
> > >>
> > >> I'm trying to configure the Kafka Appender with the programmatic
> > >> configuration described in the manuals. So I created the
> > >> ConfigurationFactory and set up the AppenderComponentBuilder.
> > >>
> > >> If I execute the Application I'll get following exception:
> > >>
> > >> Caused by: org.apache.kafka.common.config.ConfigException: Missing
> > >> required configuration "bootstrap.servers" which has no default value.
> > >>
> > >> Obviously the property "bootstrap.servers" hasn't been set.
> > >>
> > >> A builder.addProperty("bootstrap.servers", "kafka.host"); doesn't
> work.
> > >> In XML the configuration looks like  > >> name="bootstrap.servers"> kafka.host.
> > >>
> > >> But how do I set this in java?
> > >>
> > >> The code looks like the following:
> > >>
> > >>static Configuration createConfiguration(final String name,
> > >> ConfigurationBuilder builder) {
> > >>
> > >>builder.setConfigurationName(name);
> > >>builder.setStatusLevel(Level.INFO);
> > >>
> > >>AppenderComponentBuilder kafkaBuilder =
> > >> builder.newAppender("KafkaLogger ", "Kafka")
> > >>.addAttribute("topic", "testTopic");
> > >>kafkaBuilder.add(builder.newLayout("PatternLayout")
> > >>.addAttribute("pattern", "%d{HH:mm:ss:SSS} |
> > >> %logger{20} | %msg%n%ex{5}"));
> > >>
> > >>builder.add(kafkaBuilder);
> > >>
> > >>builder.add(builder.newRootLogger(Level.INFO).add(
> > >> builder.newAppenderRef("KafkaLogger")));
> > >>
> > >>return builder.build();
> > >>}
> > >>
> > >> Hope someone can help me.
> > >>
> > >> Thanks and BR,
> > >> Marvin
> > >>
> > >
> > >
> > >
> > > --
> > > Matt Sicker 
> >
> >
> >
> > -
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
>
>
> --
> Matt Sicker 
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Kafka Appender with Programmatic Configuration

2017-03-31 Thread Mikael Ståldal
https://issues.apache.org/jira/browse/LOG4J2-1860

On Thu, Mar 30, 2017 at 5:27 PM, Matt Sicker  wrote:

> I think so. That'd be less confusing.
>
> On 30 March 2017 at 02:43, Mikael Ståldal 
> wrote:
>
> > Would it make sense to have shortcuts for Property and KeyValuePair,
> since
> > they are generic and used by several appenders/layouts?
> >
> > On Wed, Mar 29, 2017 at 7:12 PM, Matt Sicker  wrote:
> >
> > > Oh, I see. That's an interesting API...
> > >
> > > On 29 March 2017 at 10:49, Marvin Geitner 
> wrote:
> > >
> > > > Thank you very much,
> > > >
> > > > kafkaBuilder.addComponent(builder.newComponent("bootstrap.servers",
> > > > "Property", "kafka.host:*9092*"));
> > > >
> > > > is working.
> > > >
> > > > BR
> > > > Marvin
> > > >
> > > > -Ursprüngliche Nachricht-
> > > > Von: Ralph Goers [mailto:ralph.go...@dslextreme.com]
> > > > Gesendet: Mittwoch, 29. März 2017 17:46
> > > > An: Log4J Users List 
> > > > Betreff: Re: Kafka Appender with Programmatic Configuration
> > > >
> > > > Mikael’s solution is correct. Every item in the ConfigurationBuilder
> > is a
> > > > Component. We have “special” Components for things that are always
> > used,
> > > > such as Loggers and Appenders. But we can’t know about every type of
> > > > Component so in those cases you just use the generic Component.
> > > >
> > > > Ralph
> > > >
> > > > > On Mar 29, 2017, at 8:26 AM, Matt Sicker  wrote:
> > > > >
> > > > > Looks like a bug to me! Here's the issue: a Properties component is
> > > > > injected into a kafka appender, but there is no way to create a
> > > > > Property or Properties component directly via the configuration
> > > > > builder API. The top level properties aren't injected in the kafka
> > > > > appender (and manager), so they're unused.
> > > > >
> > > > > Interestingly enough, I don't see a way to inject KeyValuePair
> > > > > components either (which is a similar plugin class in log4j-core).
> > > > >
> > > > > Could you make an issue here:
> > > > > https://issues.apache.org/jira/browse/LOG4J2
> > > > >
> > > > > On 29 March 2017 at 09:27, Marvin Geitner 
> > > wrote:
> > > > >
> > > > >> Hi all,
> > > > >>
> > > > >> I'm trying to configure the Kafka Appender with the programmatic
> > > > >> configuration described in the manuals. So I created the
> > > > >> ConfigurationFactory and set up the AppenderComponentBuilder.
> > > > >>
> > > > >> If I execute the Application I'll get following exception:
> > > > >>
> > > > >> Caused by: org.apache.kafka.common.config.ConfigException:
> Missing
> > > > >> required configuration "bootstrap.servers" which has no default
> > value.
> > > > >>
> > > > >> Obviously the property "bootstrap.servers" hasn't been set.
> > > > >>
> > > > >> A builder.addProperty("bootstrap.servers", "kafka.host"); doesn't
> > > work.
> > > > >> In XML the configuration looks like  > > > >> name="bootstrap.servers"> kafka.host.
> > > > >>
> > > > >> But how do I set this in java?
> > > > >>
> > > > >> The code looks like the following:
> > > > >>
> > > > >>static Configuration createConfiguration(final String name,
> > > > >> ConfigurationBuilder builder) {
> > > > >>
> > > > >>builder.setConfigurationName(name);
> > > > >>builder.setStatusLevel(Level.INFO);
> > > > >>
> > > > >>AppenderComponentBuilder kafkaBuilder =
> > > > >> builder.newAppender("KafkaLogger ", "Kafka")
> > > > >>.addAttribute("topic", "testTopic");
> > > > >>kafkaBuilder.add(builder.newLayout("PatternLayout")
> > > > >>.addAttribute("patt

Re: Can one class log to different files depending on context?

2017-04-03 Thread Mikael Ståldal
Have you tried to use RoutingAppender (
https://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender)
together with thread context?

On Mon, Apr 3, 2017 at 5:29 PM, Gerard Gagliano  wrote:

> I have a structure as follows: Class A is started via main method Class A
> starts Class B using ProcessBuilder (via main method of course) Class B
> starts Class C using its Constructor
> I want each class to have its own log and to use a single log4j2.xml file.
>
> Appender has the following:
>
>  name="file"
> fileName="${sys:loggingFileName}.log"
> …
> 
>
> Each Class has code similar to this:
>
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.core.LoggerContext;
> import org.slf4j.LoggerFactory;
>
> private static final Logger log = LoggerFactory.getLogger (A.class);
>
> System.setProperty ("loggingFileName", “A”);
> LoggerContext context = (LoggerContext) LogManager.getContext (false);
>
> If there were only these classes involved, everything would work, but
> there are many other classes that do logging.
>
> For example, Class D is referenced by Classes A, B, and C and only has
> this code:
>
> private static final Logger log = LoggerFactory.getLogger (D.class);
>
> I would like the output from Class D referenced from Class A to be in log
> A, but it may wind up in log A, B, or C.
>
> Is there a way to construct the logs so that output for Class D winds up
> in: log A when referenced from A log B when referenced from B log C when
> referenced from C.
>
>
>
>
> --
> Gerard Gagliano
> 505-792-3331 Office
> 505-463-3999 Mobile
>
> Prodentity
> Corrales, NM 87048-6935
> http://www.prodentity.com <http://www.prodentity.com/>
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Kafka Appender with Programmatic Configuration

2017-04-05 Thread Mikael Ståldal
But how do you do this for KeyValuePair?

When I do:

LayoutComponentBuilder gelfBuilder = builder.newLayout("GelfLayout");
gelfBuilder.addAttribute("host", "myself");
gelfBuilder.addComponent(builder.newComponent("foo", "KeyValuePair", "bar"));

it doesn't work and I get this error message:

ERROR KeyValuePair contains an invalid element or attribute "name"

It seems like the problem is that KeyValuePair have a "key" field, but
builder.newComponent()
assumes that it has a "name" field (like Property).

On Wed, Mar 29, 2017 at 5:46 PM, Ralph Goers 
wrote:

> Mikael’s solution is correct. Every item in the ConfigurationBuilder is a
> Component. We have “special” Components for things that are always used,
> such as Loggers and Appenders. But we can’t know about every type of
> Component so in those cases you just use the generic Component.
>
> Ralph
>
> > On Mar 29, 2017, at 8:26 AM, Matt Sicker  wrote:
> >
> > Looks like a bug to me! Here's the issue: a Properties component is
> > injected into a kafka appender, but there is no way to create a Property
> or
> > Properties component directly via the configuration builder API. The top
> > level properties aren't injected in the kafka appender (and manager), so
> > they're unused.
> >
> > Interestingly enough, I don't see a way to inject KeyValuePair components
> > either (which is a similar plugin class in log4j-core).
> >
> > Could you make an issue here: https://issues.apache.org/
> jira/browse/LOG4J2
> >
> > On 29 March 2017 at 09:27, Marvin Geitner  wrote:
> >
> >> Hi all,
> >>
> >> I'm trying to configure the Kafka Appender with the programmatic
> >> configuration described in the manuals. So I created the
> >> ConfigurationFactory and set up the AppenderComponentBuilder.
> >>
> >> If I execute the Application I'll get following exception:
> >>
> >> Caused by: org.apache.kafka.common.config.ConfigException: Missing
> >> required configuration "bootstrap.servers" which has no default value.
> >>
> >> Obviously the property "bootstrap.servers" hasn't been set.
> >>
> >> A builder.addProperty("bootstrap.servers", "kafka.host"); doesn't work.
> >> In XML the configuration looks like 
> >> kafka.host.
> >>
> >> But how do I set this in java?
> >>
> >> The code looks like the following:
> >>
> >>static Configuration createConfiguration(final String name,
> >> ConfigurationBuilder builder) {
> >>
> >>builder.setConfigurationName(name);
> >>builder.setStatusLevel(Level.INFO);
> >>
> >>AppenderComponentBuilder kafkaBuilder = builder.newAppender("
> KafkaLogger
> >> ", "Kafka")
> >>.addAttribute("topic", "testTopic");
> >>kafkaBuilder.add(builder.newLayout("PatternLayout")
> >>.addAttribute("pattern", "%d{HH:mm:ss:SSS} | %logger{20}
> |
> >> %msg%n%ex{5}"));
> >>
> >>builder.add(kafkaBuilder);
> >>
> >>builder.add(builder.newRootLogger(Level.INFO).add(
> >> builder.newAppenderRef("KafkaLogger")));
> >>
> >>return builder.build();
> >>}
> >>
> >> Hope someone can help me.
> >>
> >> Thanks and BR,
> >> Marvin
> >>
> >
> >
> >
> > --
> > Matt Sicker 
>
>
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Kafka Appender with Programmatic Configuration

2017-04-05 Thread Mikael Ståldal
It works to do it like this:

gelfBuilder.addComponent(builder.newComponent("KeyValuePair").addAttribute(
"key", "foo").addAttribute("value", "bar"));

Is there no simpler way to do it?

On Wed, Apr 5, 2017 at 2:01 PM, Mikael Ståldal 
wrote:

> But how do you do this for KeyValuePair?
>
> When I do:
>
> LayoutComponentBuilder gelfBuilder = builder.newLayout("GelfLayout");
> gelfBuilder.addAttribute("host", "myself");
> gelfBuilder.addComponent(builder.newComponent("foo", "KeyValuePair", "bar"));
>
> it doesn't work and I get this error message:
>
> ERROR KeyValuePair contains an invalid element or attribute "name"
>
> It seems like the problem is that KeyValuePair have a "key" field, but
> builder.newComponent()
> assumes that it has a "name" field (like Property).
>
> On Wed, Mar 29, 2017 at 5:46 PM, Ralph Goers 
> wrote:
>
>> Mikael’s solution is correct. Every item in the ConfigurationBuilder is a
>> Component. We have “special” Components for things that are always used,
>> such as Loggers and Appenders. But we can’t know about every type of
>> Component so in those cases you just use the generic Component.
>>
>> Ralph
>>
>> > On Mar 29, 2017, at 8:26 AM, Matt Sicker  wrote:
>> >
>> > Looks like a bug to me! Here's the issue: a Properties component is
>> > injected into a kafka appender, but there is no way to create a
>> Property or
>> > Properties component directly via the configuration builder API. The top
>> > level properties aren't injected in the kafka appender (and manager), so
>> > they're unused.
>> >
>> > Interestingly enough, I don't see a way to inject KeyValuePair
>> components
>> > either (which is a similar plugin class in log4j-core).
>> >
>> > Could you make an issue here: https://issues.apache.org/jira
>> /browse/LOG4J2
>> >
>> > On 29 March 2017 at 09:27, Marvin Geitner 
>> wrote:
>> >
>> >> Hi all,
>> >>
>> >> I'm trying to configure the Kafka Appender with the programmatic
>> >> configuration described in the manuals. So I created the
>> >> ConfigurationFactory and set up the AppenderComponentBuilder.
>> >>
>> >> If I execute the Application I'll get following exception:
>> >>
>> >> Caused by: org.apache.kafka.common.config.ConfigException: Missing
>> >> required configuration "bootstrap.servers" which has no default value.
>> >>
>> >> Obviously the property "bootstrap.servers" hasn't been set.
>> >>
>> >> A builder.addProperty("bootstrap.servers", "kafka.host"); doesn't
>> work.
>> >> In XML the configuration looks like 
>> >> kafka.host.
>> >>
>> >> But how do I set this in java?
>> >>
>> >> The code looks like the following:
>> >>
>> >>static Configuration createConfiguration(final String name,
>> >> ConfigurationBuilder builder) {
>> >>
>> >>builder.setConfigurationName(name);
>> >>builder.setStatusLevel(Level.INFO);
>> >>
>> >>AppenderComponentBuilder kafkaBuilder =
>> builder.newAppender("KafkaLogger
>> >> ", "Kafka")
>> >>.addAttribute("topic", "testTopic");
>> >>kafkaBuilder.add(builder.newLayout("PatternLayout")
>> >>.addAttribute("pattern", "%d{HH:mm:ss:SSS} |
>> %logger{20} |
>> >> %msg%n%ex{5}"));
>> >>
>> >>builder.add(kafkaBuilder);
>> >>
>> >>builder.add(builder.newRootLogger(Level.INFO).add(
>> >> builder.newAppenderRef("KafkaLogger")));
>> >>
>> >>return builder.build();
>> >>}
>> >>
>> >> Hope someone can help me.
>> >>
>> >> Thanks and BR,
>> >> Marvin
>> >>
>> >
>> >
>> >
>> > --
>> > Matt Sicker 
>>
>>
>>
>> -
>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>>
>>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.stal...@magine.com
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Buffering in Console Appender?

2017-04-18 Thread Mikael Ståldal
If you add this, don't forget to do some performance tests to verify that
it actually improves performance.

On Fri, Apr 14, 2017 at 1:33 PM, Jaromir Hamala 
wrote:

> Hello Matt,
>
> thanks for you reply. I realized this is something what should
> probably be handled inside Surefire and not inside Log4J.
>
> I'll talk to Surefire folks.
>
> Cheers,
> Jaromir
>
> On Thu, Apr 13, 2017 at 7:23 PM, Matt Sicker  wrote:
>
> > Sounds like an interesting use case. Patches are always welcome! Make
> sure
> > to file a JIRA ticket as well so we have something to refer to in the
> > changelog.
> >
> > On 13 April 2017 at 09:29, Jaromir Hamala 
> > wrote:
> >
> > > Hello,
> > >
> > > I wonder whether log4j could add (optional) buffering into the Console
> > > Appender.
> > > I believe it could be useful e.g. when the stdout is redirected to a
> file
> > > (think of Maven Surefire), etc.
> > >
> > > Would you accept a patch adding this?
> > >
> > > Cheers,
> > > Jaromir
> > >
> > > --
> > > “Perfection is achieved, not when there is nothing more to add, but
> when
> > > there is nothing left to take away.”
> > > Antoine de Saint Exupéry
> > >
> >
> >
> >
> > --
> > Matt Sicker 
> >
>
>
>
> --
> “Perfection is achieved, not when there is nothing more to add, but when
> there is nothing left to take away.”
> Antoine de Saint Exupéry
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Custom Fields in JsonLayout

2017-05-08 Thread Mikael Ståldal
There is a JIRA ticket already:
https://issues.apache.org/jira/browse/LOG4J2-1694

On Sat, May 6, 2017 at 7:59 PM, Volkan Yazıcı 
wrote:

> Hello,
>
> In Log4j 2.x, I want to introduce custom fields to JsonLayout via
> configuration. Is that something doable? Or shall I come back with a JIRA
> ticket+patch?
>
> Best.
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.stal...@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.


Re: Failing to initialize log4j2 configuration dynamically

2017-07-04 Thread Mikael Ståldal
This is a bit strange from a JSON standpoint though, since the order of 
properties in a JSON object is not supposed to be significant.



On 2017-07-04 19:54, Ralph Goers wrote:

This is not a bug but is intentional. Log4j processes configuration files from 
beginning to end. It does not scan the file twice as would be necessary if no 
order was required. Properties MUST come first so that they can be used by the 
configuration that follows. Because of that we will generate an error if the 
properties are encountered after some other element is found.

Ralph


On Jul 4, 2017, at 1:35 AM, Roman Sosnin  wrote:

Hi,

Opened PR in Github:
https://github.com/apache/logging-log4j2/pull/91
Thanks.

Regards,
Roman Sosnin
Backend Server Side Developer
Trusteer Security
IBM Israel Software Lab



From:   Gary Gregory 
To: Log4J Users List 
Date:   20/06/2017 06:01
Subject:Re: Failing to initialize log4j2 configuration dynamically



My guess is that it's a bug. Can't be sure until we see a failing unit
test. At least, that's the easiest way.

Gary

On Wed, Jun 21, 2017 at 12:06 AM, Roman Sosnin  wrote:


Hi,

Yea I've opened a Jira ticket for this issue. I will create a failing

unit

test as soon as I can & then upload it.

For now any thoughts? Bug ? API Misuse?

Thanks

Regards,
Roman Sosnin
Backend Server Side Developer
Trusteer Security
IBM Israel Software Lab
Office: +972-(0)74-7922783



From:   Gary Gregory 
To: Log4J Users List 
Date:   18/06/2017 19:14
Subject:Re: Failing to initialize log4j2 configuration

dynamically




I think there is a Jira ticket already about this, if not, do create one
please. Are you available to create a failing unit test? A patch for a

fix

as well perhaps?

Gary

On Jun 18, 2017 3:00 AM, "Roman Sosnin"  wrote:


Failing to initialize log4j2 configuration dynamically - supplying a

JSON

configuration node while json nodes are in random order.

Environment: Linux - CentOS 6
Component/s: Configurators
Affects Version/s: 2.8.1

For example, this one works for me:
"configuration":
{ "status":"...", "name":"...", "properties":"...", "appenders":"...",
"loggers":"..." }
But this one fails:
"configuration":
{ "status":"...", "name":"...", "appenders":"...", "loggers":"...",
"properties":"..." }
PAY ATTENTION: "properties" node is the last node and not 3rd.
Initializing the config programmatically this way:
JsonNode logObject =
ConfigManager.getInstance().getContainerDefinition().at(
CONFIG_LOGGING_JAVA_NODE);
InputStream stream = new
ByteArrayInputStream(logObject.toString().getBytes());
ConfigurationSource source = new ConfigurationSource(stream);
Configuration ourConfig = new
JsonConfiguration(LoggerContext.getContext(), source);
Configurator.initialize(ourConfig);
where logObject is the actual log4j2 JSON config node.
Any thoughts? Bug? API Misuse?

Thanks!

Regards,
Roman Sosnin
Backend Server Side Developer
Trusteer Security
IBM Israel Software Lab
Office: +972-(0)74-7922783

















-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org




-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Failing to initialize log4j2 configuration dynamically

2017-07-05 Thread Mikael Ståldal
From a JSON standpoint, it would make sense to look up the nodes by 
name and ignore the order. Should be fairly easy I guess?



On 2017-07-05 01:26, Ralph Goers wrote:

Like all of our configurations, the JSON input is read as a tree of nodes. In 
all of our configurations, first we grab all the attributes from the root node 
- those represent the attributes on the Configuration node. Then all the 
JSON/XML/YAML/Properties nodes are converted to configuration Nodes. At that 
point AbstractConfiguration takes over and performs the actual configuration - 
it is agnostic of the input format.  Currently AbstractConfiguration in the 
doConfigure() method requires that the Properties node be the very first node 
in the configuration (for the reasons I stated before). You could change that 
to find the Properties node as any child element of Configuration but that will 
affect every Configuration implementation, not just JSON.

Ralph


On Jul 4, 2017, at 2:08 PM, Gary Gregory  wrote:

On Jul 4, 2017 13:50, "Mikael Ståldal"  wrote:

This is a bit strange from a JSON standpoint though, since the order of
properties in a JSON object is not supposed to be significant.


Agreed. What is the best way forward though?

Gary




On 2017-07-04 19:54, Ralph Goers wrote:


This is not a bug but is intentional. Log4j processes configuration files
from beginning to end. It does not scan the file twice as would be
necessary if no order was required. Properties MUST come first so that they
can be used by the configuration that follows. Because of that we will
generate an error if the properties are encountered after some other
element is found.

Ralph

On Jul 4, 2017, at 1:35 AM, Roman Sosnin  wrote:


Hi,

Opened PR in Github:
https://github.com/apache/logging-log4j2/pull/91
Thanks.

Regards,
Roman Sosnin
Backend Server Side Developer
Trusteer Security
IBM Israel Software Lab



From:   Gary Gregory 
To: Log4J Users List 
Date:   20/06/2017 06:01
Subject:Re: Failing to initialize log4j2 configuration dynamically



My guess is that it's a bug. Can't be sure until we see a failing unit
test. At least, that's the easiest way.

Gary

On Wed, Jun 21, 2017 at 12:06 AM, Roman Sosnin 
wrote:

Hi,


Yea I've opened a Jira ticket for this issue. I will create a failing


unit


test as soon as I can & then upload it.

For now any thoughts? Bug ? API Misuse?

Thanks

Regards,
Roman Sosnin
Backend Server Side Developer
Trusteer Security
IBM Israel Software Lab
Office: +972-(0)74-7922783



From:   Gary Gregory 
To: Log4J Users List 
Date:   18/06/2017 19:14
Subject:Re: Failing to initialize log4j2 configuration


dynamically





I think there is a Jira ticket already about this, if not, do create one
please. Are you available to create a failing unit test? A patch for a


fix


as well perhaps?

Gary

On Jun 18, 2017 3:00 AM, "Roman Sosnin"  wrote:

Failing to initialize log4j2 configuration dynamically - supplying a



JSON


configuration node while json nodes are in random order.

Environment: Linux - CentOS 6
Component/s: Configurators
Affects Version/s: 2.8.1

For example, this one works for me:
"configuration":
{ "status":"...", "name":"...", "properties":"...", "appenders":"...",
"loggers":"..." }
But this one fails:
"configuration":
{ "status":"...", "name":"...", "appenders":"...", "loggers":"...",
"properties":"..." }
PAY ATTENTION: "properties" node is the last node and not 3rd.
Initializing the config programmatically this way:
JsonNode logObject =
ConfigManager.getInstance().getContainerDefinition().at(
CONFIG_LOGGING_JAVA_NODE);
InputStream stream = new
ByteArrayInputStream(logObject.toString().getBytes());
ConfigurationSource source = new ConfigurationSource(stream);
Configuration ourConfig = new
JsonConfiguration(LoggerContext.getContext(), source);
Configurator.initialize(ourConfig);
where logObject is the actual log4j2 JSON config node.
Any thoughts? Bug? API Misuse?

Thanks!

Regards,
Roman Sosnin
Backend Server Side Developer
Trusteer Security
IBM Israel Software Lab
Office: +972-(0)74-7922783

















-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org




-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org




-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org




-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Failing to initialize log4j2 configuration dynamically

2017-07-07 Thread Mikael Ståldal
I agree that this is not the higest priority, and not a blocker for 2.9 
release.



On 2017-07-05 23:31, Ralph Goers wrote:

Feel free to take a look at the code. There a lot of other Jira issues that I 
think merit attention over this though, especially since I don’t consider it to 
be a problem.

Ralph


On Jul 5, 2017, at 12:18 PM, Mikael Ståldal  wrote:

 From a JSON standpoint, it would make sense to look up the nodes by name and 
ignore the order. Should be fairly easy I guess?


On 2017-07-05 01:26, Ralph Goers wrote:

Like all of our configurations, the JSON input is read as a tree of nodes. In 
all of our configurations, first we grab all the attributes from the root node 
- those represent the attributes on the Configuration node. Then all the 
JSON/XML/YAML/Properties nodes are converted to configuration Nodes. At that 
point AbstractConfiguration takes over and performs the actual configuration - 
it is agnostic of the input format.  Currently AbstractConfiguration in the 
doConfigure() method requires that the Properties node be the very first node 
in the configuration (for the reasons I stated before). You could change that 
to find the Properties node as any child element of Configuration but that will 
affect every Configuration implementation, not just JSON.
Ralph

On Jul 4, 2017, at 2:08 PM, Gary Gregory  wrote:

On Jul 4, 2017 13:50, "Mikael Ståldal"  wrote:

This is a bit strange from a JSON standpoint though, since the order of
properties in a JSON object is not supposed to be significant.


Agreed. What is the best way forward though?

Gary




On 2017-07-04 19:54, Ralph Goers wrote:


This is not a bug but is intentional. Log4j processes configuration files
from beginning to end. It does not scan the file twice as would be
necessary if no order was required. Properties MUST come first so that they
can be used by the configuration that follows. Because of that we will
generate an error if the properties are encountered after some other
element is found.

Ralph

On Jul 4, 2017, at 1:35 AM, Roman Sosnin  wrote:


Hi,

Opened PR in Github:
https://github.com/apache/logging-log4j2/pull/91
Thanks.

Regards,
Roman Sosnin
Backend Server Side Developer
Trusteer Security
IBM Israel Software Lab



From:   Gary Gregory 
To: Log4J Users List 
Date:   20/06/2017 06:01
Subject:Re: Failing to initialize log4j2 configuration dynamically



My guess is that it's a bug. Can't be sure until we see a failing unit
test. At least, that's the easiest way.

Gary

On Wed, Jun 21, 2017 at 12:06 AM, Roman Sosnin 
wrote:

Hi,


Yea I've opened a Jira ticket for this issue. I will create a failing


unit


test as soon as I can & then upload it.

For now any thoughts? Bug ? API Misuse?

Thanks

Regards,
Roman Sosnin
Backend Server Side Developer
Trusteer Security
IBM Israel Software Lab
Office: +972-(0)74-7922783



From:   Gary Gregory 
To: Log4J Users List 
Date:   18/06/2017 19:14
Subject:Re: Failing to initialize log4j2 configuration


dynamically





I think there is a Jira ticket already about this, if not, do create one
please. Are you available to create a failing unit test? A patch for a


fix


as well perhaps?

Gary

On Jun 18, 2017 3:00 AM, "Roman Sosnin"  wrote:

Failing to initialize log4j2 configuration dynamically - supplying a



JSON


configuration node while json nodes are in random order.

Environment: Linux - CentOS 6
Component/s: Configurators
Affects Version/s: 2.8.1

For example, this one works for me:
"configuration":
{ "status":"...", "name":"...", "properties":"...", "appenders":"...",
"loggers":"..." }
But this one fails:
"configuration":
{ "status":"...", "name":"...", "appenders":"...", "loggers":"...",
"properties":"..." }
PAY ATTENTION: "properties" node is the last node and not 3rd.
Initializing the config programmatically this way:
JsonNode logObject =
ConfigManager.getInstance().getContainerDefinition().at(
CONFIG_LOGGING_JAVA_NODE);
InputStream stream = new
ByteArrayInputStream(logObject.toString().getBytes());
ConfigurationSource source = new ConfigurationSource(stream);
Configuration ourConfig = new
JsonConfiguration(LoggerContext.getContext(), source);
Configurator.initialize(ourConfig);
where logObject is the actual log4j2 JSON config node.
Any thoughts? Bug? API Misuse?

Thanks!

Regards,
Roman Sosnin
Backend Server Side Developer
Trusteer Security
IBM Israel Software Lab
Office: +972-(0)74-7922783

















-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org





Re: Desire for a Gitter channel?

2017-07-25 Thread Mikael Ståldal
I would prefer if we could chose one or the other, and not have both at 
the same time.



On 2017-07-24 18:46, Matt Sicker wrote:

This link was posted on another mailing list recently in criticism of
Slack: https://bitquabit.com/post/i-hate-slack-and-you-should-too/

On 18 July 2017 at 09:12, Chandra 
wrote:


Having used both paid and free service (of slack), I’d say the paid
service makes a lot of sense for corporates.
a public forum like this I believe a free tier would suffice — unless we
are looking for an option of having >10k messages for searching + >5gb of
storage [1]. This is just my opinion, but people think otherwise and I
believe some-biased opinions on Flock too[2].

thanks,

Chandra
[1] https://dev-s.slack.com/pricing
[2] https://www.quora.com/What-are-the-pros-and-cons-of-Gitter-vs-Slack

On 18 Jul 2017, 7:29 PM +0530, Marshall Schor , wrote:

what's the diff between gitter and hipchat?

Google search seems to maybe be saying hipchat is better for many.

We have already Hipchat available, I think. (We've added it to our

project,

Apache UIMA).

-Marshall Schor


On 7/17/2017 10:20 PM, Matt Sicker wrote:

Gitter is public. And Slack is a paid service (free version has a lot

of

limits), so it's not very feasible for public chats without someone

funding

it. Gitter, however, is free for all GitHub projects (and Gitlab too I
think?) and is even open source now that Gitlab owns them.

On 17 July 2017 at 21:13, Tungathurthi, Chandra Kiran Bharadwaj <
chandra.tungathur...@rwth-aachen.de> wrote:


Hey actually, a slack channel would fit right in. Any specific

reason to

choose gitter over slack ? @matt

thanks & regards,
Chandra


From: Gary Gregory
Sent: Tuesday, 18 July, 07:08
Subject: Re: Desire for a Gitter channel?
To: Log4J Users List

So, like a private Slack? Bah, why not, as long as we make sure to
document any and all decisions on the ML, it could be OK. Gary On

Mon, Jul

17, 2017 at 11:35 AM, Matt Sicker wrote: >

https://gitter.im/apache/home

We can request a log4j Gitter channel for realtime chat. This

could be

handy for quick questions and other things that waiting on Stack

Overflow

or mailing list posts isn't as appropriate for. > > This would be

very

different from the ASF Slack as it is open to everyone. > > Also, I

find

chat rooms a bit easier to reply to while at work than > browsing

Stack

Overflow. ;) > > -- > Matt Sicker


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Article about logging practices

2017-08-01 Thread Mikael Ståldal

Yes, good article.

I find this advice a bit strange though:

"Add a log for every else in your code."


On 2017-07-30 23:25, Matt Sicker wrote:

https://dev.to/grhegde09/logging-done-right-makes-your-life-bright

Thought this was an interesting take on a lot of the best practices
encouraged by Log4j. The article covers logging in the realm of C
applications, but it's all mostly relevant to Java and JVM languages as
well.


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: Fwd: Add json object to log4j2 when is JSONLayout

2017-08-11 Thread Mikael Ståldal
Note that if we add such option to JsonLayout, then all log messages 
passed to that layout need to be well-formed JSON, otherwise the output 
will not be well-formed JSON. We would make it easy for the user to 
shoot himself in the foot.


I think it would be better to create a new subclass of Message, 
JsonMessage, and let JsonLayout handle such messages specially and 
output as a nested JSON structure (instead as a quoted and escaped 
string as today).


However, how do we represent a JSON structure without adding dependency 
on Jackson or other 3rd party JSON library? Message subcasses are in 
log4j-api, and we do not want log4j-api to depend on any such library. 
Or maybe we should put this new JsonMessage in log4j-core? Or maybe put 
it in a new log4j-json module?


Should we also have XmlMessage for XmlLayout?

What about YamlLayout?


On 2017-08-11 16:56, Gary Gregory wrote:

Hello,

The JSON layout outputs the log event in JSON, the event message is just a
string in that event, in this case, it is escaped following the JSON rules
to remain a string.

If you want a JSON object back out of the event message you will have to
parse it out of that string.

Feel free to provide a PR on GitHub if you want to add an option to allow
for a JSON object as the log message. I am not sure if it would be accepted
though as it is quite different from the current design.

Thoughts from the community?

Gary


On Aug 11, 2017 07:53, "Jeus Geek"  wrote:

i will show JSON object as a JSON object in log4j2 when is that configed
JSONLayout .

JSON object:

{"line_id": 12,"play_name":"Jeus"}

import org.apache.logging.log4j.LogManager;import
org.apache.logging.log4j.Logger;
public class Main {

private static final Logger LOGGER = LogManager.getLogger(Main.
class);

public static void main(String[] args) {


 String message = "{\"line_id\": 12,\"play_name\": \"Jeus\"}";
 LOGGER.info(message);

 }
  }

output is:

{
  "timeMillis":1502361394238,
  "thread":"main",
  "level":"INFO",
  "loggerName":"com.jeus.logger.json.loggerjson.Main",
  "message":"{\"line_id\": 12,\"play_name\": \"Jeus\"}",
  "endOfBatch":false,
  "loggerFqcn":"org.apache.logging.log4j.spi.AbstractLogger",
  "contextMap":[

  ],
  "threadId":1,
  "threadPriority":5,
  "source":{
 "class":"com.jeus.logger.json.loggerjson.Main",
 "method":"main",
 "file":"Main.java",
 "line":62
 }
  }

but i will show message as a json object same this:

  "message":{"line_id": 12,"play_name":"Jeus"},

you can see more detail about my problem in stackOverflow



thank you for attention




-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: log4j2.xml won't get read

2017-09-23 Thread Mikael Ståldal
I don't know how Wildfly works, but maybe you should ask this question 
to any support forum of Wildfly.



On 2017-09-19 13:16, Christian Wansart wrote:

Hello,

I am working on a jax-rs project that uses log4j through slf4j-api and 
log4j-slf4j-impl. So far, I configured the logging pattern via Wildfly’s 
standalone.xml. But I want to have a project wide config file for logging.

I put a log4j2.xml in the resources folder, but when I run it, it just uses the 
pattern of the standalone.xml.

Here is my log4j2.xml:

   
   
 
   
 
   
 
 
   
 
   
 
   

What am I missing? It seems that the file was not read?  In the output in my 
IntelliJ IDEA IDE I just see the log messages in the format I set in the 
standalone.xml.

Best regards,
Christian


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org




-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: HTTPAPPENDER

2017-10-24 Thread Mikael Ståldal
Elasic.co got it wrong in that blog post. The problem is not 
SockerAppender, the problem is SerializedLayout.


Maybe people were confusing the two, since SerializedLayout used to be 
default layout for SockerAppender. But it has always been possible to 
configure SockerAppender to use another layout. And since Log4j 2.9.0, 
SerializedLayout is deprecated and no longer default in any appender.


You can use SockerAppender with JsonLayout for sending log events to 
Logstash.



On 2017-10-24 08:25, itsg...@gmail.com wrote:

Thanks. We have a situation where we have a thick client application (Java
Swing) and we want the client side logs to be pushed to server side so that
we can use for analysis. Socketappender is one option but looks like there
are plan to depricate socket appenders because of security issues. Please
refer to below
https://www.elastic.co/blog/log4j-input-logstash




--
Sent from: http://apache-logging.6191.n7.nabble.com/Log4j-Users-f4.html

-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org




-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: log4j2 properties config?

2017-11-23 Thread Mikael Ståldal
Log4j 2 has properties based configuration (since version 2.4), but it 
is a different format than Log4j 1.x, not compatible.


https://logging.apache.org/log4j/2.x/manual/configuration.html#Properties


On 2017-11-23 14:00, Alex O'Ree wrote:

Did log4j 2 drop support for the properties based configuration file?




-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



  1   2   >