custum logback parser not working

Here developers can talk about how to write a Parser for LogMX

Moderator: admin

Post Reply
mcervinka
Posts: 2
Joined: Wed Apr 20, 2016 7:37 am

custum logback parser not working

Post by mcervinka » Wed Apr 20, 2016 4:50 pm

Hello,
I've defined custom logback parser using pattern which is using our application - just copy&paste from configuration file.
But LogMX can't parse any line. I am wondreing why?

Can you please put your clever eye on this? :-)


Here is the pattern:

Code: Select all

%d{ISO8601} [${serverId}, ${MACHINE}, %thread, %X{REQUEST_URI}, %X{REQUEST_ID}, %X{SESSION_ID}, %X{SOURCE_SYSTEM}, %X{CORRELATION_ID}] %-5level %logger{36} - %msg%n%xEx{7}
And here are few lines of the application log (original file was UTF-8 encoded,

Code: Select all

2016-04-14 11:50:03,632 [app-natco, MACHINE_IS_UNDEFINED, localhost-startStop-1, , , , , , , ] INFO  c.c.d.l.c.c.conf.AppProfilesSetup - APP started with profiles: [jndiDataSource, postgreSql, prod, hcs]
2016-04-14 11:50:15,462 [app-natco, MACHINE_IS_UNDEFINED, localhost-startStop-1, , , , , , , ] WARN  o.s.b.f.config.PropertiesFactoryBean - Could not load properties from class path resource [alerts.cfg]: class path resource [alerts.cfg] cannot be opened because it does not exist
2016-04-14 11:50:15,462 [app-natco, MACHINE_IS_UNDEFINED, localhost-startStop-1, , , , , , , ] WARN  o.s.b.f.config.PropertiesFactoryBean - Could not load properties from class path resource [alerts0.cfg]: class path resource [alerts0.cfg] cannot be opened because it does not exist
2016-04-14 11:50:15,463 [app-natco, MACHINE_IS_UNDEFINED, localhost-startStop-1, , , , , , , ] WARN  o.s.b.f.config.PropertiesFactoryBean - Could not load properties from class path resource [extensions0.cfg]: class path resource [extensions0.cfg] cannot be opened because it does not exist
2016-04-14 11:50:16,220 [app-natco, MACHINE_IS_UNDEFINED, localhost-startStop-1, , , , , , , ] WARN  o.a.c.i.c.DefaultTypeConverter - Overriding type converter from: StaticMethodTypeConverter: public static java.io.InputStream org.apache.camel.component.http4.HttpConverter.toInputStream(javax.servlet.http.HttpServletRequest,org.apache.camel.Exchange) throws java.io.IOException to: StaticMethodTypeConverter: public static java.io.InputStream org.apache.camel.component.http.HttpConverter.toInputStream(javax.servlet.http.HttpServletRequest,org.apache.camel.Exchange) throws java.io.IOException
2016-04-14 11:50:16,220 [app-natco, MACHINE_IS_UNDEFINED, localhost-startStop-1, , , , , , , ] WARN  o.a.c.i.c.DefaultTypeConverter - Overriding type converter from: StaticMethodTypeConverter: public static javax.servlet.http.HttpServletRequest org.apache.camel.component.http4.HttpConverter.toServletRequest(org.apache.camel.Message) to: StaticMethodTypeConverter: public static javax.servlet.http.HttpServletRequest org.apache.camel.component.http.HttpConverter.toServletRequest(org.apache.camel.Message)
2016-04-14 11:50:16,220 [app-natco, MACHINE_IS_UNDEFINED, localhost-startStop-1, , , , , , , ] WARN  o.a.c.i.c.DefaultTypeConverter - Overriding type converter from: StaticMethodTypeConverter: public static javax.servlet.http.HttpServletResponse org.apache.camel.component.http4.HttpConverter.toServletResponse(org.apache.camel.Message) to: StaticMethodTypeConverter: public static javax.servlet.http.HttpServletResponse org.apache.camel.component.http.HttpConverter.toServletResponse(org.apache.camel.Message)
2016-04-14 11:50:28,490 [app-natco, MACHINE_IS_UNDEFINED, Thread-2, , , , , , , ] INFO  c.c.d.l.c.c.s.c.SmppConsumer$2 - Trying to reconnect to smpp://2994@127.0.0.1:2775 - attempt #1...
2016-04-14 11:50:29,206 [app-natco, MACHINE_IS_UNDEFINED, Thread-2, , , , , , , ] INFO  c.c.d.l.c.c.s.c.SmppConsumer$2 - Reconnected to smpp://2994@127.0.0.1:2775
2016-04-14 11:51:00,004 [app-natco, MACHINE_IS_UNDEFINED, DefaultQuartzScheduler-camelContext_Worker-5, , , , , , , ] INFO  c.c.d.l.m.i.s.MisconfiguredDevicePoolerRoute - Task [APP/MisconfiguredDevicePooler] was started.
2016-04-14 11:51:00,012 [app-natco, MACHINE_IS_UNDEFINED, DefaultQuartzScheduler-camelContext_Worker-5, , , , , , , ] WARN  org.apache.camel.util.EventHelper - Error notifying event ID-app-natco-46949-1460627415777-0-10 exchange Exchange[Message: [Body is null]] sending to: Endpoint[direct://AppJobs-MisconfiguredDevicePooler_task_route]. This exception will be ignored. 
java.lang.IllegalArgumentException: request must not be empty
	at org.springframework.util.Assert.hasText(Assert.java:162) ~[spring-core-3.2.4.RELEASE.jar:3.2.4.RELEASE]
	at org.cleverbus.api.entity.Request.createRequest(Request.java:109) ~[cleverbus-core-api-1.3.1-20160413.024914-258.jar:1.3.1-SNAPSHOT]
	at org.cleverbus.core.reqres.RequestSendingEventNotifier.doNotify(RequestSendingEventNotifier.java:96) ~[cleverbus-core-1.3.1-20160413.025111-258.jar:1.3.1-SNAPSHOT]
	at org.cleverbus.core.reqres.RequestSendingEventNotifier.doNotify(RequestSendingEventNotifier.java:49) ~[cleverbus-core-1.3.1-20160413.025111-258.jar:1.3.1-SNAPSHOT]
	at org.cleverbus.api.event.EventNotifierBase.notify(EventNotifierBase.java:54) ~[cleverbus-core-api-1.3.1-20160413.024914-258.jar:1.3.1-SNAPSHOT]
	at org.apache.camel.util.EventHelper.doNotifyEvent(EventHelper.java:771) [camel-core-2.13.2.jar:2.13.2]
	at org.apache.camel.util.EventHelper.notifyExchangeSending(EventHelper.java:577) [camel-core-2.13.2.jar:2.13.2]
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:108) [camel-core-2.13.2.jar:2.13.2]
2016-04-14 11:51:00,054 [app-natco, MACHINE_IS_UNDEFINED, DefaultQuartzScheduler-camelContext_Worker-5, , , , , aeb5b83c-258c-41d5-a52f-6992d539f6e2, SCHEDULER, ] INFO  c.c.d.l.m.i.s.MisconfiguredDevicePoolerRoute - Task [APP/MisconfiguredDevicePooler] was finished.
THX

admin
Site Admin
Posts: 419
Joined: Sun Dec 17, 2006 10:30 pm

Re: custum logback parser not working

Post by admin » Wed Apr 20, 2016 11:16 pm

Hello,

The issue comes from the two "${}" parameters in your pattern (${serverId}, ${MACHINE}): in fact, Logback replaces this with something you may give at run-time. So to make it work, simply replace $ with %X just like other fields:

Code: Select all

%d{ISO8601} [%X{serverId}, %X{MACHINE}, %thread, %X{REQUEST_URI}, %X{REQUEST_ID}, %X{SESSION_ID}, %X{SOURCE_SYSTEM}, %X{CORRELATION_ID}] %-5level %logger{36} - %msg%n%xEx{7}
instead of:

Code: Select all

%d{ISO8601} [${serverId}, ${MACHINE}, %thread, %X{REQUEST_URI}, %X{REQUEST_ID}, %X{SESSION_ID}, %X{SOURCE_SYSTEM}, %X{CORRELATION_ID}] %-5level %logger{36} - %msg%n%xEx{7}
Moreover, it seems that you have 8 fields between [] in your pattern, but your log file contains 10 fields between these []. LogMX doesn't fail for that, but your last field will be interpreted as ", , ".

Please let me know if you have any other trouble.

Xavier

mcervinka
Posts: 2
Joined: Wed Apr 20, 2016 7:37 am

Re: custum logback parser not working

Post by mcervinka » Thu Apr 21, 2016 12:18 pm

Thank You Xavier, now it is working well!

Post Reply