Re: markers
Android have these levels ( http://developer.android.com/reference/android/util/Log.html): ERROR WARN INFO DEBUG VERBOSE Adding VERBOSE above DEBUG would be inconsistent with Android and thus confusing. On Thu, Sep 17, 2015 at 12:24 AM, Gary Gregory <garydgreg...@gmail.com> wrote: > At first I was going to strongly recommend against using a custom level > called BUSINESS. Custom levels have been a problem in the past at my work > (IMO). Markers are really a perfect fit for this use-case. That got me to > thinking about my previous idea on this of adding more levels to Log4j. > Please bear with me. Today we have: > > OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL > > What I could use today are *these* levels too: > > OFF > *EXIT* > FATAL > ERROR > WARN > *HEADLINE* > INFO > *VERBOSE* > DEBUG > TRACE > ALL > > (EXIT is called when you System.exit(), which might not be loggable > depending on I don't know what, HEADLINE is a lame name but I can't think > of anything better, VERBOSE is obvious IMO) > > Which made me wonder if your BUSINESS level could fit in like this: > > OFF > FATAL > ERROR > WARN > *BUSINESS* > INFO > DEBUG > TRACE > ALL > > So maybe, just maybe, I could see that a BUSINESS level makes sense instead > of a marker. > > Gary > > > On Wed, Sep 16, 2015 at 2:34 PM, Nicholas Duane <nic...@msn.com> wrote: > > > I was hoping on getting some replies to my last message as I'm trying to > > figure out the best way to utilize the existing logging frameworks, > > log4j(2) and log4net in our case, to log our business events and ensure > the > > business events flow to the correct destination. > > > > I think the two main suggestions were to either use markers or a separate > > "well known" logger. > > > > As I mentioned in the previous message, I was about to write a sample > > which used markers just to better understand how they work. The first > road > > block I ran into is that log4net does not support markers, as far as I > can > > tell. Now the implementation doesn't have to be the same on both windows > > and linux, but that would certainly be a plus if it was. Also, it > doesn't > > look like markers have been heavily adopted by many logging frameworks. > > The one article I read only listed log4j2 and logback. > > > > In addition, while markers seem like they would be better at indicating > > the type or category of event as opposed to using a level, you still have > > to define a marker for each type I guess. I could either define a custom > > level or a custom marker. Since markers are not available in log4net and > > custom levels are, a custom level might work out better for us. > > > > Using a "well known" logger to log business events seems like a > reasonable > > approach. And while I don't see any major downsides with going this > route, > > it seems that a piece of code which is logging using their own logger > > should be able to log a business event with that same logger. It was > > stated previously that the level indicates the importance of the event > and > > the logger indicates the types of events, or why someone might want to > look > > at the events. The example given was some market data code which used > its > > own logger to log market data information. That seems totally > reasonable, > > however, it doesn't seem to fit my example. In our case any component > can > > emit a business event. > > > > I then thought that maybe I could use the EventLogger, which I think > > someone might have mentioned along the way. I was hoping to try that out > > also, assuming that allowed me to pass a marker in whatever methods it > > exposed. However, I only see a static marker property on the EventLogger > > class. > > > > The other option which I'm considering is exposing a property on my event > > object which indicates the category of event. At the moment I have a > > "type" property which, of course, indicates the event type. However, > this > > will be different for every different business event and thus I need > > another property which tells me that the event is a "business" event. > Then > > I was thinking I could write a filter which checks the message object to > > see if it's one of my events and if so use the "category" to forward to > the > > appropriate destination. > > > > Am I missing any other viable solutions? > > > > Thanks, > > Nick > > > > > From: nic...@m
RE: markers
I was hoping on getting some replies to my last message as I'm trying to figure out the best way to utilize the existing logging frameworks, log4j(2) and log4net in our case, to log our business events and ensure the business events flow to the correct destination. I think the two main suggestions were to either use markers or a separate "well known" logger. As I mentioned in the previous message, I was about to write a sample which used markers just to better understand how they work. The first road block I ran into is that log4net does not support markers, as far as I can tell. Now the implementation doesn't have to be the same on both windows and linux, but that would certainly be a plus if it was. Also, it doesn't look like markers have been heavily adopted by many logging frameworks. The one article I read only listed log4j2 and logback. In addition, while markers seem like they would be better at indicating the type or category of event as opposed to using a level, you still have to define a marker for each type I guess. I could either define a custom level or a custom marker. Since markers are not available in log4net and custom levels are, a custom level might work out better for us. Using a "well known" logger to log business events seems like a reasonable approach. And while I don't see any major downsides with going this route, it seems that a piece of code which is logging using their own logger should be able to log a business event with that same logger. It was stated previously that the level indicates the importance of the event and the logger indicates the types of events, or why someone might want to look at the events. The example given was some market data code which used its own logger to log market data information. That seems totally reasonable, however, it doesn't seem to fit my example. In our case any component can emit a business event. I then thought that maybe I could use the EventLogger, which I think someone might have mentioned along the way. I was hoping to try that out also, assuming that allowed me to pass a marker in whatever methods it exposed. However, I only see a static marker property on the EventLogger class. The other option which I'm considering is exposing a property on my event object which indicates the category of event. At the moment I have a "type" property which, of course, indicates the event type. However, this will be different for every different business event and thus I need another property which tells me that the event is a "business" event. Then I was thinking I could write a filter which checks the message object to see if it's one of my events and if so use the "category" to forward to the appropriate destination. Am I missing any other viable solutions? Thanks, Nick > From: nic...@msn.com > 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 > > > >
Re: markers
At first I was going to strongly recommend against using a custom level called BUSINESS. Custom levels have been a problem in the past at my work (IMO). Markers are really a perfect fit for this use-case. That got me to thinking about my previous idea on this of adding more levels to Log4j. Please bear with me. Today we have: OFF FATAL ERROR WARN INFO DEBUG TRACE ALL What I could use today are *these* levels too: OFF *EXIT* FATAL ERROR WARN *HEADLINE* INFO *VERBOSE* DEBUG TRACE ALL (EXIT is called when you System.exit(), which might not be loggable depending on I don't know what, HEADLINE is a lame name but I can't think of anything better, VERBOSE is obvious IMO) Which made me wonder if your BUSINESS level could fit in like this: OFF FATAL ERROR WARN *BUSINESS* INFO DEBUG TRACE ALL So maybe, just maybe, I could see that a BUSINESS level makes sense instead of a marker. Gary On Wed, Sep 16, 2015 at 2:34 PM, Nicholas Duane <nic...@msn.com> wrote: > I was hoping on getting some replies to my last message as I'm trying to > figure out the best way to utilize the existing logging frameworks, > log4j(2) and log4net in our case, to log our business events and ensure the > business events flow to the correct destination. > > I think the two main suggestions were to either use markers or a separate > "well known" logger. > > As I mentioned in the previous message, I was about to write a sample > which used markers just to better understand how they work. The first road > block I ran into is that log4net does not support markers, as far as I can > tell. Now the implementation doesn't have to be the same on both windows > and linux, but that would certainly be a plus if it was. Also, it doesn't > look like markers have been heavily adopted by many logging frameworks. > The one article I read only listed log4j2 and logback. > > In addition, while markers seem like they would be better at indicating > the type or category of event as opposed to using a level, you still have > to define a marker for each type I guess. I could either define a custom > level or a custom marker. Since markers are not available in log4net and > custom levels are, a custom level might work out better for us. > > Using a "well known" logger to log business events seems like a reasonable > approach. And while I don't see any major downsides with going this route, > it seems that a piece of code which is logging using their own logger > should be able to log a business event with that same logger. It was > stated previously that the level indicates the importance of the event and > the logger indicates the types of events, or why someone might want to look > at the events. The example given was some market data code which used its > own logger to log market data information. That seems totally reasonable, > however, it doesn't seem to fit my example. In our case any component can > emit a business event. > > I then thought that maybe I could use the EventLogger, which I think > someone might have mentioned along the way. I was hoping to try that out > also, assuming that allowed me to pass a marker in whatever methods it > exposed. However, I only see a static marker property on the EventLogger > class. > > The other option which I'm considering is exposing a property on my event > object which indicates the category of event. At the moment I have a > "type" property which, of course, indicates the event type. However, this > will be different for every different business event and thus I need > another property which tells me that the event is a "business" event. Then > I was thinking I could write a filter which checks the message object to > see if it's one of my events and if so use the "category" to forward to the > appropriate destination. > > Am I missing any other viable solutions? > > Thanks, > Nick > > > From: nic...@msn.com > > 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 &
RE: markers
First of all let me say that I'm not trying to keep posing the same question until you guys agree with me. I'm just trying to make sure I've done my due diligence to root out all possible options so that I can pick the one which ends up working out the best for our needs. That being said, while I agree that a "Business" level doesn't quite fit the existing level vernacular, as was stated before, it does seem like having a level might help. If all the methods which could be used to log the event take a level, I'm going to need to choose one. Choosing INFO or ERROR or FATAL, etc., for logging a "Business" event seems a bit odd. And while I said we want to make it such that you can't turn off these events, that's probably not correct. If for some reason something goes wrong and we start flooding the system with business events we may need to turn them off. However, we'll still probably want to capture INFO, ERROR, WARN and FATAL events from a systems management perspective. This is where I was thinking having level be an enumeration as opposed to a scale might come in handy. I could enumerate the exact levels I want and where I want them to go as opposed to level being a gauge where everything at that level and more specific match. Your example below is good. I'm not sure how closely it matches with a "business" level as the custom levels you chose do see to fit better within the currently defined levels. I was really thinking that maybe the EventLogger() with a marker might work out well. The reason is that the EventLogger() has an overload which doesn't take a level, I guess the default level is "OFF" which means it's always logged? However, it appears I can't pass a marker to the EventLogger() log() method. That in addition to log4net not supporting markers is making this a less viable option. Thanks, Nick > Date: Wed, 16 Sep 2015 15:24:20 -0700 > Subject: Re: markers > From: garydgreg...@gmail.com > To: log4j-user@logging.apache.org > > At first I was going to strongly recommend against using a custom level > called BUSINESS. Custom levels have been a problem in the past at my work > (IMO). Markers are really a perfect fit for this use-case. That got me to > thinking about my previous idea on this of adding more levels to Log4j. > Please bear with me. Today we have: > > OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL > > What I could use today are *these* levels too: > > OFF > *EXIT* > FATAL > ERROR > WARN > *HEADLINE* > INFO > *VERBOSE* > DEBUG > TRACE > ALL > > (EXIT is called when you System.exit(), which might not be loggable > depending on I don't know what, HEADLINE is a lame name but I can't think > of anything better, VERBOSE is obvious IMO) > > Which made me wonder if your BUSINESS level could fit in like this: > > OFF > FATAL > ERROR > WARN > *BUSINESS* > INFO > DEBUG > TRACE > ALL > > So maybe, just maybe, I could see that a BUSINESS level makes sense instead > of a marker. > > Gary > > > On Wed, Sep 16, 2015 at 2:34 PM, Nicholas Duane <nic...@msn.com> wrote: > > > I was hoping on getting some replies to my last message as I'm trying to > > figure out the best way to utilize the existing logging frameworks, > > log4j(2) and log4net in our case, to log our business events and ensure the > > business events flow to the correct destination. > > > > I think the two main suggestions were to either use markers or a separate > > "well known" logger. > > > > As I mentioned in the previous message, I was about to write a sample > > which used markers just to better understand how they work. The first road > > block I ran into is that log4net does not support markers, as far as I can > > tell. Now the implementation doesn't have to be the same on both windows > > and linux, but that would certainly be a plus if it was. Also, it doesn't > > look like markers have been heavily adopted by many logging frameworks. > > The one article I read only listed log4j2 and logback. > > > > In addition, while markers seem like they would be better at indicating > > the type or category of event as opposed to using a level, you still have > > to define a marker for each type I guess. I could either define a custom > > level or a custom marker. Since markers are not available in log4net and > > custom levels are, a custom level might work out better for us. > > > > Using a "well known" logger to log business events seems like a reasonable > > approach. And while I don't see any major downsides with going this route, > > it seems that a piece of code which is logging usi
Re: markers
I actually haven’t looked at log4net, but since it predates Log4j 2 I would imagine it is missing the new features we added. Using your own custom messages is certainly a viable approach. But there again, logging Message objects instead of simple strings is something that was introduced by Log4j 2. As far as I know no other logging framework supports that. But it would definitely give you the flexibility you are looking for. You could create your own API to create various Business Messages and then create a Filter (or Filters) for them. In addition this gives you some control over how the messages are formatted, both through the getFormattedMessage method and by using a custom Layout. The EventLogger is a pretty simple class and can be used if you only want to distinguish a single kind of event. But it does provide a good example for you to follow if you want to do something similar for your business events - you could create separate methods for each type of event and use a different maker and or message type for each. The EventLogger is essentially a global logger, so using it from a class that has its own logger doesn’t really feel all that unnatural when you are logging “normal” debug or info messages through a class logger and logging your business events through the EventLogger (or similar). Ralph > On Sep 16, 2015, at 2:34 PM, Nicholas Duane <nic...@msn.com> wrote: > > I was hoping on getting some replies to my last message as I'm trying to > figure out the best way to utilize the existing logging frameworks, log4j(2) > and log4net in our case, to log our business events and ensure the business > events flow to the correct destination. > > I think the two main suggestions were to either use markers or a separate > "well known" logger. > > As I mentioned in the previous message, I was about to write a sample which > used markers just to better understand how they work. The first road block I > ran into is that log4net does not support markers, as far as I can tell. Now > the implementation doesn't have to be the same on both windows and linux, but > that would certainly be a plus if it was. Also, it doesn't look like markers > have been heavily adopted by many logging frameworks. The one article I read > only listed log4j2 and logback. > > In addition, while markers seem like they would be better at indicating the > type or category of event as opposed to using a level, you still have to > define a marker for each type I guess. I could either define a custom level > or a custom marker. Since markers are not available in log4net and custom > levels are, a custom level might work out better for us. > > Using a "well known" logger to log business events seems like a reasonable > approach. And while I don't see any major downsides with going this route, > it seems that a piece of code which is logging using their own logger should > be able to log a business event with that same logger. It was stated > previously that the level indicates the importance of the event and the > logger indicates the types of events, or why someone might want to look at > the events. The example given was some market data code which used its own > logger to log market data information. That seems totally reasonable, > however, it doesn't seem to fit my example. In our case any component can > emit a business event. > > I then thought that maybe I could use the EventLogger, which I think someone > might have mentioned along the way. I was hoping to try that out also, > assuming that allowed me to pass a marker in whatever methods it exposed. > However, I only see a static marker property on the EventLogger class. > > The other option which I'm considering is exposing a property on my event > object which indicates the category of event. At the moment I have a "type" > property which, of course, indicates the event type. However, this will be > different for every different business event and thus I need another property > which tells me that the event is a "business" event. Then I was thinking I > could write a filter which checks the message object to see if it's one of my > events and if so use the "category" to forward to the appropriate destination. > > Am I missing any other viable solutions? > > Thanks, > Nick > >> From: nic...@msn.com >> 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,
markers
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
Custom Markers
Hi, I am currently using log4j2.0 and I have implemented Marker (SYSLOG_MARKER) for deciding the destination of a log to be localfile log or syslog. But with this approach all the existing logs in the system (~5000) will need manual decision and addition of marker to every single log. Is there a better way to filter logs at INFO level? I don't want to introduce a new level. Thanks, Priya Ahuja
Re: Custom Markers
If I understand you correctly, you have an existing application that logs events in about 5000 different places, so you don’t want to have to modify that code. Without modifying the code the only way to filter the events is on somehow find something wiithin the message itself. If you can add the marker only to the message you want routed. Ralph > On Sep 10, 2015, at 11:38 AM, Priya Ahujawrote: > > Hi, > > I am currently using log4j2.0 and I have implemented Marker (SYSLOG_MARKER) > for deciding the destination of a log to be localfile log or syslog. But > with this approach all the existing logs in the system (~5000) will need > manual decision and addition of marker to every single log. Is there a > better way to filter logs at INFO level? I don't want to introduce a new > level. > > > > > > onMismatch="DENY"/> > > > > > > Thanks, > Priya Ahuja - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Custom Markers
Gee whiz, that wasn’t very clear. Let’s try again. Without modifying the code the only way I can think of to filter the events is to find something within the message itself to filter on. If you can add the marker only to the events you want routed then the configuration you have below will work. You can also create a special logger just for logging the events that are to be routed. However, both of those require that code be modified. Ralph > On Sep 10, 2015, at 2:40 PM, Ralph Goerswrote: > > If I understand you correctly, you have an existing application that logs > events in about 5000 different places, so you don’t want to have to modify > that code. > > Without modifying the code the only way to filter the events is on somehow > find something wiithin the message itself. If you can add the marker only to > the message you want routed. > > Ralph > > >> On Sep 10, 2015, at 11:38 AM, Priya Ahuja wrote: >> >> Hi, >> >> I am currently using log4j2.0 and I have implemented Marker (SYSLOG_MARKER) >> for deciding the destination of a log to be localfile log or syslog. But >> with this approach all the existing logs in the system (~5000) will need >> manual decision and addition of marker to every single log. Is there a >> better way to filter logs at INFO level? I don't want to introduce a new >> level. >> >> >> >> >> >> > onMismatch="DENY"/> >> >> >> >> >> >> Thanks, >> Priya Ahuja > > > > - > 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
Using markers or ThreadContext to select logger via slf4j
I have some libraries that leverage slf4j for logging (can't change it) however my application leverages log4j2 and the slf4j-log4j2 bridge. I was wondering if there is a way I can at the beginning of the request flow set a value in the ThreadContext or something so that the slf4j loggers will route to a specific log4j2 logger instead of the root logger. Is this possible? Thanks, James
Re: Using markers or ThreadContext to select logger via slf4j
What do you mean by “request flow”? You can certainly do this in your code. Ralph On Dec 19, 2014, at 6:10 AM, James Hutton james.a.hut...@gmail.com wrote: I have some libraries that leverage slf4j for logging (can't change it) however my application leverages log4j2 and the slf4j-log4j2 bridge. I was wondering if there is a way I can at the beginning of the request flow set a value in the ThreadContext or something so that the slf4j loggers will route to a specific log4j2 logger instead of the root logger. Is this possible? Thanks, James - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Using markers or ThreadContext to select logger via slf4j
So for example a cxf interceptor that is using slf4j internally, I'd like to add an interceptor before it to add items to the ThreadContext that would cause getLogger(Class) to return a different logger based upon the value set in the ThreadContext. On Fri, Dec 19, 2014 at 9:55 AM, Ralph Goers ralph.go...@dslextreme.com wrote: What do you mean by “request flow”? You can certainly do this in your code. Ralph On Dec 19, 2014, at 6:10 AM, James Hutton james.a.hut...@gmail.com wrote: I have some libraries that leverage slf4j for logging (can't change it) however my application leverages log4j2 and the slf4j-log4j2 bridge. I was wondering if there is a way I can at the beginning of the request flow set a value in the ThreadContext or something so that the slf4j loggers will route to a specific log4j2 logger instead of the root logger. Is this possible? Thanks, James - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Unable to create detached markers via log4j-slf4j-impl 2.1.
Hi Ralph, I worked around the issue. Basically, I had a setup where I had basic markers A, B and a marker C which existed in 2 versions: 1) C - with reference to A and 2) C with reference to B. What I did instead was create 2 separate markers. C_A with references to C and A and C_B with references to C and B. Regards, /David On 10 November 2014 21:46, Ralph Goers ralph.go...@dslextreme.com wrote: Yes, that should be documented. Log4j 2 doesn’t currently support detached markers. If you can create a Jira issue for this and why a detached marker is required we can consider it. However, detached markers introduce some performance and thread safety issues so we would really need to understand the benefit so we can weigh it against the cost. Ralph On Nov 10, 2014, at 9:32 AM, David KOCH dk...@ezakus.com wrote: Hello, I am unable to create detached versions of existing markers when using log4j2 through the slf4j facade - log4j2 version is 2.1. Example: import org.slf4j.Marker; import org.slf4j.MarkerFactory; public class TestMarker { public static void main(String[] args) { Marker markerA = MarkerFactory.getMarker(testA); Marker markerB = MarkerFactory.getMarker(testB); markerA.add(markerB); Marker markerANew = MarkerFactory.getDetachedMarker(testA); // Iteration below will fail if this line is uncommented. //System.out.println(Removing reference from detached markerA: + markerANew.remove(markerB)); System.out.println(Has reference marker A: + markerA.hasReferences()); System.out.println(Has reference detached marker A: + markerANew.hasReferences()); IteratorMarker mRef = markerA.iterator(); while (mRef.hasNext()) { System.out.println(mRef.next().getName()); } mRef = markerANew.iterator(); while (mRef.hasNext()) { System.out.println(mRef.next().getName()); } } } Actual output: Has reference marker A: true Has reference detached marker A: true Expected output (which I get when using native slf4j logging implementation logback): Has reference marker A: true Has reference detached marker A: false I am trying to keep my application log framework agnostic but it seems like it's not possible in this case. Since it's currently impossible via log4j-slf4j-impl, is there a pure log4j2 way of getting detached marker instances? The feature is quite important to us since marker names and references both play important parts in how we route and parse our logs. Thank you, Regards, /David - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org