You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "raulvk.soa" <ra...@gmail.com> on 2008/09/16 11:32:39 UTC

Custom log messages

Hi,

Is there any possibility to print custom log lines on log files? For
example, via de "log:" component?

My requirement is to print out not only the contents and the attributes of
the message, but also a line describing in which point of the processing
sequence the message actually is.

Thanks.

-- 
View this message in context: http://www.nabble.com/Custom-log-messages-tp19508418s22882p19508418.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: [SPAM] Re: Custom log messages

Posted by Roman Kalukiewicz <ro...@gmail.com>.
What about still using to() but WITH some other body, like

with(el("This is my body: ${body}")).to("log:my.log")

so it works in a similar way as multicast modifies the behaviour of
to() (example: multicast().to(a, b, c))

or in opposite way

to(log:my.log).with(el(...))

What do you think? I just believe that then it is clear that we simply
sending the message.

My $0.02

Roman

2008/9/16 Claus Ibsen <ci...@silverbullet.dk>:
> Hi
>
> +1 to Spawn. And I guess fork is also a word in the category.
>
> However the pattern smells like the wiretap pattern. What's the difference here? The camel example is just a pipeline where the message is sent to the wire tap before it's processed by the real route. I got the impression from the EIP book that this was in 2 threads. That the wire tap is running in its own thread, and the original route runs in the original thread.
>
> http://activemq.apache.org/camel/wire-tap.html
> http://www.enterpriseintegrationpatterns.com/WireTap.html
>
>
>
> Med venlig hilsen
>
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> -----Original Message-----
> From: James Strachan [mailto:james.strachan@gmail.com]
> Sent: 16. september 2008 18:14
> To: camel-user@activemq.apache.org
> Subject: [SPAM] Re: Custom log messages
>
> 2008/9/16 raulvk.soa <ra...@gmail.com>:
>>
>> Hi,
>>
>> Just a contribution.
>>
>> I think a good verb for this action would be "branch". Correct me if I am
>> wrong, but what you are actually doint is spawning a new thread that would
>> do some further processing on a copy of the initial message, and once the
>> thread is done, the Exchange object associated with it would be scrapped
>> away. In the parallel, the main processing flow would continue within the
>> main, core branch.
>>
>> So I suggest something like:
>>
>> from("jbi:xxx")
>>    .branch().log("Transforming message. Source: {in.message}",
>> <loggingCategory>)
>>    .to("jbi:service:http://mycompany.org/SaxonTransformMessage")
>>    .branch().log("Message transformed. Result: {out.message}",
>> <loggingCategory>);
>>
>> The branch() action actually creates a copy of the current message in the
>> pipeline and spawns a new thread that executes the following actions.
>>
>> In my imagination, the log() method would create a new header in the message
>> that contains the specified log message, and would immediately invoke a new
>> LogProcessor that would take the message out from this header, substitute
>> the tokens with the appropriate content, and finally call the Logger
>> associated with the specified logging category.
>>
>> What do you think?
>>
>> From a user's point of view, I honestly believe the clearest keyword to use
>> for this new pattern is "branch()".
>
> I like it. Another suggestion to throw into the mix, I wonder what
> folks think of "spawn" - thinking unix processes; spawning up a
> separate process etc.
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>

RE: [SPAM] Re: Custom log messages

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

+1 to Spawn. And I guess fork is also a word in the category.

However the pattern smells like the wiretap pattern. What's the difference here? The camel example is just a pipeline where the message is sent to the wire tap before it's processed by the real route. I got the impression from the EIP book that this was in 2 threads. That the wire tap is running in its own thread, and the original route runs in the original thread.

http://activemq.apache.org/camel/wire-tap.html
http://www.enterpriseintegrationpatterns.com/WireTap.html



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: James Strachan [mailto:james.strachan@gmail.com] 
Sent: 16. september 2008 18:14
To: camel-user@activemq.apache.org
Subject: [SPAM] Re: Custom log messages

2008/9/16 raulvk.soa <ra...@gmail.com>:
>
> Hi,
>
> Just a contribution.
>
> I think a good verb for this action would be "branch". Correct me if I am
> wrong, but what you are actually doint is spawning a new thread that would
> do some further processing on a copy of the initial message, and once the
> thread is done, the Exchange object associated with it would be scrapped
> away. In the parallel, the main processing flow would continue within the
> main, core branch.
>
> So I suggest something like:
>
> from("jbi:xxx")
>    .branch().log("Transforming message. Source: {in.message}",
> <loggingCategory>)
>    .to("jbi:service:http://mycompany.org/SaxonTransformMessage")
>    .branch().log("Message transformed. Result: {out.message}",
> <loggingCategory>);
>
> The branch() action actually creates a copy of the current message in the
> pipeline and spawns a new thread that executes the following actions.
>
> In my imagination, the log() method would create a new header in the message
> that contains the specified log message, and would immediately invoke a new
> LogProcessor that would take the message out from this header, substitute
> the tokens with the appropriate content, and finally call the Logger
> associated with the specified logging category.
>
> What do you think?
>
> From a user's point of view, I honestly believe the clearest keyword to use
> for this new pattern is "branch()".

I like it. Another suggestion to throw into the mix, I wonder what
folks think of "spawn" - thinking unix processes; spawning up a
separate process etc.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Custom log messages

Posted by James Strachan <ja...@gmail.com>.
2008/9/16 raulvk.soa <ra...@gmail.com>:
>
> Hi,
>
> Just a contribution.
>
> I think a good verb for this action would be "branch". Correct me if I am
> wrong, but what you are actually doint is spawning a new thread that would
> do some further processing on a copy of the initial message, and once the
> thread is done, the Exchange object associated with it would be scrapped
> away. In the parallel, the main processing flow would continue within the
> main, core branch.
>
> So I suggest something like:
>
> from("jbi:xxx")
>    .branch().log("Transforming message. Source: {in.message}",
> <loggingCategory>)
>    .to("jbi:service:http://mycompany.org/SaxonTransformMessage")
>    .branch().log("Message transformed. Result: {out.message}",
> <loggingCategory>);
>
> The branch() action actually creates a copy of the current message in the
> pipeline and spawns a new thread that executes the following actions.
>
> In my imagination, the log() method would create a new header in the message
> that contains the specified log message, and would immediately invoke a new
> LogProcessor that would take the message out from this header, substitute
> the tokens with the appropriate content, and finally call the Logger
> associated with the specified logging category.
>
> What do you think?
>
> From a user's point of view, I honestly believe the clearest keyword to use
> for this new pattern is "branch()".

I like it. Another suggestion to throw into the mix, I wonder what
folks think of "spawn" - thinking unix processes; spawning up a
separate process etc.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Custom log messages

Posted by "raulvk.soa" <ra...@gmail.com>.
Hi,

Just a contribution.

I think a good verb for this action would be "branch". Correct me if I am
wrong, but what you are actually doint is spawning a new thread that would
do some further processing on a copy of the initial message, and once the
thread is done, the Exchange object associated with it would be scrapped
away. In the parallel, the main processing flow would continue within the
main, core branch.

So I suggest something like:

from("jbi:xxx")
    .branch().log("Transforming message. Source: {in.message}",
<loggingCategory>)      
    .to("jbi:service:http://mycompany.org/SaxonTransformMessage")
    .branch().log("Message transformed. Result: {out.message}",
<loggingCategory>);

The branch() action actually creates a copy of the current message in the
pipeline and spawns a new thread that executes the following actions.

In my imagination, the log() method would create a new header in the message
that contains the specified log message, and would immediately invoke a new
LogProcessor that would take the message out from this header, substitute
the tokens with the appropriate content, and finally call the Logger
associated with the specified logging category.

What do you think?

>From a user's point of view, I honestly believe the clearest keyword to use
for this new pattern is "branch()".

Raul.


Gert Vanthienen wrote:
> 
> James,
> 
> We could also look at it from the interceptor end and improve that so it 
> knows where it is being invoked in the route.  For example: if the 
> interceptor knows about the previous/next step in the route is, it can 
> also log other messages based on where in the route it is (or omit 
> logging for some steps).
> 
> Regards,
> 
> Gert
> 
> James Strachan wrote:
>> Btw, isn't it possible to do the same thing with an interceptor?
>>   
>>
>> Yeah you could do the same thing with an interceptor - I was just
>> thinking that you'd maybe want a specific logging message each time
>> its used. I guess an analogy is, I was pondering about whats the Camel
>> DSL equivalent of shoving in a LOG.info("foo") inside any line of a
>> route definition - which doesn't affect the flow at all. You can use
>> the tracer or add an interceptor to always log each step; but
>> sometimes you just wanna insert custom messages at specific points.
>>
>>   
> 
> 
> 
> -----
> ---
> Gert Vanthienen
> http://www.anova.be
> 

-- 
View this message in context: http://www.nabble.com/Custom-log-messages-tp19508418s22882p19514692.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Custom log messages

Posted by Gert Vanthienen <ge...@skynet.be>.
James,

We could also look at it from the interceptor end and improve that so it 
knows where it is being invoked in the route.  For example: if the 
interceptor knows about the previous/next step in the route is, it can 
also log other messages based on where in the route it is (or omit 
logging for some steps).

Regards,

Gert

James Strachan wrote:
> Btw, isn't it possible to do the same thing with an interceptor?
>   
>
> Yeah you could do the same thing with an interceptor - I was just
> thinking that you'd maybe want a specific logging message each time
> its used. I guess an analogy is, I was pondering about whats the Camel
> DSL equivalent of shoving in a LOG.info("foo") inside any line of a
> route definition - which doesn't affect the flow at all. You can use
> the tracer or add an interceptor to always log each step; but
> sometimes you just wanna insert custom messages at specific points.
>
>   


Re: Custom log messages

Posted by James Strachan <ja...@gmail.com>.
2008/9/16 Gert Vanthienen <ge...@skynet.be>:
> James,
>
> How does trigger() sound?
>  from("..").trigger("direct:log").to("something:else");
>  from("direct:log")...

Not sure :). Naming is so hard! :) We might all need to sleep on this
one a bit to get a great name that seems to fit. Maybe something
longer and more explicit?
e.g.

forwardTransformedBodyTo(uri).xpath("/foo/bar")


> Btw, isn't it possible to do the same thing with an interceptor?

Yeah you could do the same thing with an interceptor - I was just
thinking that you'd maybe want a specific logging message each time
its used. I guess an analogy is, I was pondering about whats the Camel
DSL equivalent of shoving in a LOG.info("foo") inside any line of a
route definition - which doesn't affect the flow at all. You can use
the tracer or add an interceptor to always log each step; but
sometimes you just wanna insert custom messages at specific points.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Custom log messages

Posted by Gert Vanthienen <ge...@skynet.be>.
James,

How does trigger() sound?
  from("..").trigger("direct:log").to("something:else");
  from("direct:log")...

Btw, isn't it possible to do the same thing with an interceptor?

Regards,

Gert

James Strachan wrote:
> 2008/9/16 James Strachan <ja...@gmail.com>:
>   
>> 2008/9/16 raulvk.soa <ra...@gmail.com>:
>>     
>>> Hi Claus,
>>>
>>> My requirement is a bit different... I need to print human-readable messages
>>> such as "Validating against XML Schema...", "Validation OK", "Validation
>>> ERROR", etc... Therefore, I need to be able to specify the message that
>>> should be printed out when I am building the route.
>>>
>>> Don't know if I have expressed myself clearly...
>>>
>>> Is there any functionality in Camel that will allow me to do send custom log
>>> messages to the Log component?
>>>       
>> You could use a templating engine to transform the message into a
>> human readable format first, before routing it to the log component.
>>
>> See...
>> http://activemq.apache.org/camel/templating.html
>>
>> for example
>>
>> from("...").
>>  to("velocity:scripts/Validating.vm").
>>  to("log:Validating");
>>
>> then your Validating.vm script could generate text extracting some
>> headers or payload from the message etc.
>>
>> Maybe if the logging information is simpler; we could just use normal
>> expressions?
>>
>> e.g. using the EL as a kinda templating engine
>>
>> from("...").
>>        setBody().el("Validating ${in.header.foo} blah").
>>        to("log:Validating");
>>
>> Templating engines come into their own when you are composing a large
>> page of text such as an email with embedded values; if its a single
>> line of text for a log message or SMS or something then using EL or
>> XPath or something might be simpler as you can inline the expression
>> inside your route.
>>     
>
>
> One thought though; imagine if you want to log at each step of a
> route; its currently a bit icky if you transform the message at each
> step. e.g.
>
> from("...").
>   multicast().
>   block().
>       setBody().el("About to invoke bean with ${body}").to("log:Foo").
>   end().
>   bean(Foo.class).
>   multicast().
>   block().
>       setBody().el("About to invoke bean with ${body}").to("log:Bar").
>   end().
>   bean(Bar.class)
>
> i.e. having to use some kinda multicast/block syntax to avoid the
> transformed log message from being used in the actual pipeline.
>
> I wonder if we can come up with some kinda neater syntax, that allows
> us to spawn off a oneway 'transform and send' type step within a route
> easier?
>
> We could add logging to the DSL for this specific use case - though it
> does feel a bit like we should make it easier to support
> transform-and-send-but-continue-with-previous-message more easily in
> the DSL. Any thoughts?
>
> For logging maybe we could do something like
>
> from("....").
>   log("SomeCategory").el("My message ${in.header.foo}").
>   bean(Foo.class).
>   log("Bar").el("About to invoke bean with ${body}").
>   bean(Bar.class);
>
> Or maybe we come up with an alternative to the "to()" method which
> takes an expression? Something like...
>
> from("....").
>   transformTo("log:SomeCategory").el("My message ${in.header.foo}").
>   bean(Foo.class).
>   transformTo("log:Bar").el("About to invoke bean with ${body}").
>   bean(Bar.class);
>
> So that transformTo() does a transform first, using the given
> expression (in the above example using EL) then sends it to the given
> endpoint - but then returns the previous message exchange? Then this
> way its not logging specific. So we could use it to fire off emails
> during the route or fire off SMS texts or whatever
>
> from("....").
>   transformTo("smtp:foo@bar.com").el("My message ${in.header.foo}").
>   bean(Foo.class).
>   transformTo("sms:1234567").el("About to invoke bean with ${body}").
>   bean(Bar.class);
>
> Am not sure about the name; transformTo() - maybe forwardTo()? Or
> forwardTransform()? Maybe it should start with "to..." as its kinda
> like to(endpoint) but just that it also takes an expression; so maybe
> "toWithTransform()" maybe?
>
> Thoughts?
>   


Re: Custom log messages

Posted by James Strachan <ja...@gmail.com>.
2008/9/16 James Strachan <ja...@gmail.com>:
> 2008/9/16 raulvk.soa <ra...@gmail.com>:
>>
>> Hi Claus,
>>
>> My requirement is a bit different... I need to print human-readable messages
>> such as "Validating against XML Schema...", "Validation OK", "Validation
>> ERROR", etc... Therefore, I need to be able to specify the message that
>> should be printed out when I am building the route.
>>
>> Don't know if I have expressed myself clearly...
>>
>> Is there any functionality in Camel that will allow me to do send custom log
>> messages to the Log component?
>
> You could use a templating engine to transform the message into a
> human readable format first, before routing it to the log component.
>
> See...
> http://activemq.apache.org/camel/templating.html
>
> for example
>
> from("...").
>  to("velocity:scripts/Validating.vm").
>  to("log:Validating");
>
> then your Validating.vm script could generate text extracting some
> headers or payload from the message etc.
>
> Maybe if the logging information is simpler; we could just use normal
> expressions?
>
> e.g. using the EL as a kinda templating engine
>
> from("...").
>        setBody().el("Validating ${in.header.foo} blah").
>        to("log:Validating");
>
> Templating engines come into their own when you are composing a large
> page of text such as an email with embedded values; if its a single
> line of text for a log message or SMS or something then using EL or
> XPath or something might be simpler as you can inline the expression
> inside your route.


One thought though; imagine if you want to log at each step of a
route; its currently a bit icky if you transform the message at each
step. e.g.

from("...").
  multicast().
  block().
      setBody().el("About to invoke bean with ${body}").to("log:Foo").
  end().
  bean(Foo.class).
  multicast().
  block().
      setBody().el("About to invoke bean with ${body}").to("log:Bar").
  end().
  bean(Bar.class)

i.e. having to use some kinda multicast/block syntax to avoid the
transformed log message from being used in the actual pipeline.

I wonder if we can come up with some kinda neater syntax, that allows
us to spawn off a oneway 'transform and send' type step within a route
easier?

We could add logging to the DSL for this specific use case - though it
does feel a bit like we should make it easier to support
transform-and-send-but-continue-with-previous-message more easily in
the DSL. Any thoughts?

For logging maybe we could do something like

from("....").
  log("SomeCategory").el("My message ${in.header.foo}").
  bean(Foo.class).
  log("Bar").el("About to invoke bean with ${body}").
  bean(Bar.class);

Or maybe we come up with an alternative to the "to()" method which
takes an expression? Something like...

from("....").
  transformTo("log:SomeCategory").el("My message ${in.header.foo}").
  bean(Foo.class).
  transformTo("log:Bar").el("About to invoke bean with ${body}").
  bean(Bar.class);

So that transformTo() does a transform first, using the given
expression (in the above example using EL) then sends it to the given
endpoint - but then returns the previous message exchange? Then this
way its not logging specific. So we could use it to fire off emails
during the route or fire off SMS texts or whatever

from("....").
  transformTo("smtp:foo@bar.com").el("My message ${in.header.foo}").
  bean(Foo.class).
  transformTo("sms:1234567").el("About to invoke bean with ${body}").
  bean(Bar.class);

Am not sure about the name; transformTo() - maybe forwardTo()? Or
forwardTransform()? Maybe it should start with "to..." as its kinda
like to(endpoint) but just that it also takes an expression; so maybe
"toWithTransform()" maybe?

Thoughts?
-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Custom log messages

Posted by James Strachan <ja...@gmail.com>.
2008/9/16 raulvk.soa <ra...@gmail.com>:
>
> Hi Claus,
>
> My requirement is a bit different... I need to print human-readable messages
> such as "Validating against XML Schema...", "Validation OK", "Validation
> ERROR", etc... Therefore, I need to be able to specify the message that
> should be printed out when I am building the route.
>
> Don't know if I have expressed myself clearly...
>
> Is there any functionality in Camel that will allow me to do send custom log
> messages to the Log component?

You could use a templating engine to transform the message into a
human readable format first, before routing it to the log component.

See...
http://activemq.apache.org/camel/templating.html

for example

from("...").
  to("velocity:scripts/Validating.vm").
  to("log:Validating");

then your Validating.vm script could generate text extracting some
headers or payload from the message etc.

Maybe if the logging information is simpler; we could just use normal
expressions?

e.g. using the EL as a kinda templating engine

from("...").
        setBody().el("Validating ${in.header.foo} blah").
        to("log:Validating");

Templating engines come into their own when you are composing a large
page of text such as an email with embedded values; if its a single
line of text for a log message or SMS or something then using EL or
XPath or something might be simpler as you can inline the expression
inside your route.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: [SPAM] Re: Custom log messages

Posted by James Strachan <ja...@gmail.com>.
2008/9/16 raulvk.soa <ra...@gmail.com>:
>
> Yep, I just realised that was possible.
>
> Do you know if there is a way to get rid of the full category name and only
> print out the last token on the log file? i.e. print out
> "ValidatingAgainstXMLSchema" instead of
> "com.mycompany.ValidatingAgainstXMLSchema".
>
> I am aware that I can truncate it at a fixed position, but I cannot
> guarantee that my final tokens will all be the same length...

Using this config tends to just print the last path of the category

log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n

For more information see
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html

i.e. use %c{x} where x is the number of right hand paths to print, so
%c{1} just prints the last one

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

RE: [SPAM] RE: [SPAM] Re: Custom log messages

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

You can do all sorts of thing with -% in log4j:
[%-15.15c]. I guess it should be possible to skip X.

Or you Can make your category very small, such as x ;

To("log:xValidatingAgainstSchma")



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
Sent: 16. september 2008 13:05
To: camel-user@activemq.apache.org
Subject: [SPAM] RE: [SPAM] Re: Custom log messages


Yep, I just realised that was possible.

Do you know if there is a way to get rid of the full category name and only
print out the last token on the log file? i.e. print out
"ValidatingAgainstXMLSchema" instead of
"com.mycompany.ValidatingAgainstXMLSchema".

I am aware that I can truncate it at a fixed position, but I cannot
guarantee that my final tokens will all be the same length...



Claus Ibsen wrote:
> 
> Hi
> 
> You can prefix the categoy (package name) with the same prefix
> 
> To("log:com.mycompany.ValidatingAgainstXMLSchema")
> To("log:com.mycompany.ValidationOK")
> 
> And have them logged in the same file
> 
> log4j.logger.com.mycompany = special
> 
> log4j.appender.special=org.apache.log4j.FileAppender
> log4j.appender.special.layout=org.apache.log4j.PatternLayout
> log4j.appender.special.layout.ConversionPattern=%d [%-15.15t] %-5p
> %-30.30c{1} - %m%n
> log4j.appender.special.file=myspecial.log
> log4j.appender.special.append=true
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: James Strachan [mailto:james.strachan@gmail.com] 
> Sent: 16. september 2008 12:34
> To: camel-user@activemq.apache.org
> Subject: [SPAM] Re: Custom log messages
> 
> 2008/9/16 raulvk.soa <ra...@gmail.com>:
>> Nevermind. Sorry I got confused. Obviously you can make different log
>> categories use the same Appender!
>>
>> That would be a temporary solution, as architecturally speaking we would
>> be
>> overloading the log4j with an awful amount of loggers, which I am not
>> happy
>> doing.
>>
>> Do you think it is feasible to achieve this by extending the Logger class
>> and using it as a processor? What method would I have to override? Any
>> special considerations? I think I may attempt to do this...
> 
> I'm not quite sure I follow. Claus's example uses a single Logger
> called "ValidatingAgainstXMLSchema" or whatever. i.e. you can use a
> single Logger if you want - the URI log:foo defines the logger to use.
> There's not one per message or anything like that. Each different log
> URI uses a different logger, so its up to you to define how many
> different logger/categories you want to use.
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Custom-log-messages-tp19508418s22882p19509593.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: [SPAM] Re: Custom log messages

Posted by "raulvk.soa" <ra...@gmail.com>.
Yep, I just realised that was possible.

Do you know if there is a way to get rid of the full category name and only
print out the last token on the log file? i.e. print out
"ValidatingAgainstXMLSchema" instead of
"com.mycompany.ValidatingAgainstXMLSchema".

I am aware that I can truncate it at a fixed position, but I cannot
guarantee that my final tokens will all be the same length...



Claus Ibsen wrote:
> 
> Hi
> 
> You can prefix the categoy (package name) with the same prefix
> 
> To("log:com.mycompany.ValidatingAgainstXMLSchema")
> To("log:com.mycompany.ValidationOK")
> 
> And have them logged in the same file
> 
> log4j.logger.com.mycompany = special
> 
> log4j.appender.special=org.apache.log4j.FileAppender
> log4j.appender.special.layout=org.apache.log4j.PatternLayout
> log4j.appender.special.layout.ConversionPattern=%d [%-15.15t] %-5p
> %-30.30c{1} - %m%n
> log4j.appender.special.file=myspecial.log
> log4j.appender.special.append=true
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: James Strachan [mailto:james.strachan@gmail.com] 
> Sent: 16. september 2008 12:34
> To: camel-user@activemq.apache.org
> Subject: [SPAM] Re: Custom log messages
> 
> 2008/9/16 raulvk.soa <ra...@gmail.com>:
>> Nevermind. Sorry I got confused. Obviously you can make different log
>> categories use the same Appender!
>>
>> That would be a temporary solution, as architecturally speaking we would
>> be
>> overloading the log4j with an awful amount of loggers, which I am not
>> happy
>> doing.
>>
>> Do you think it is feasible to achieve this by extending the Logger class
>> and using it as a processor? What method would I have to override? Any
>> special considerations? I think I may attempt to do this...
> 
> I'm not quite sure I follow. Claus's example uses a single Logger
> called "ValidatingAgainstXMLSchema" or whatever. i.e. you can use a
> single Logger if you want - the URI log:foo defines the logger to use.
> There's not one per message or anything like that. Each different log
> URI uses a different logger, so its up to you to define how many
> different logger/categories you want to use.
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Custom-log-messages-tp19508418s22882p19509593.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: [SPAM] Re: Custom log messages

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

You can prefix the categoy (package name) with the same prefix

To("log:com.mycompany.ValidatingAgainstXMLSchema")
To("log:com.mycompany.ValidationOK")

And have them logged in the same file

log4j.logger.com.mycompany = special

log4j.appender.special=org.apache.log4j.FileAppender
log4j.appender.special.layout=org.apache.log4j.PatternLayout
log4j.appender.special.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
log4j.appender.special.file=myspecial.log
log4j.appender.special.append=true



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: James Strachan [mailto:james.strachan@gmail.com] 
Sent: 16. september 2008 12:34
To: camel-user@activemq.apache.org
Subject: [SPAM] Re: Custom log messages

2008/9/16 raulvk.soa <ra...@gmail.com>:
> Nevermind. Sorry I got confused. Obviously you can make different log
> categories use the same Appender!
>
> That would be a temporary solution, as architecturally speaking we would be
> overloading the log4j with an awful amount of loggers, which I am not happy
> doing.
>
> Do you think it is feasible to achieve this by extending the Logger class
> and using it as a processor? What method would I have to override? Any
> special considerations? I think I may attempt to do this...

I'm not quite sure I follow. Claus's example uses a single Logger
called "ValidatingAgainstXMLSchema" or whatever. i.e. you can use a
single Logger if you want - the URI log:foo defines the logger to use.
There's not one per message or anything like that. Each different log
URI uses a different logger, so its up to you to define how many
different logger/categories you want to use.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Custom log messages

Posted by James Strachan <ja...@gmail.com>.
2008/9/16 raulvk.soa <ra...@gmail.com>:
> Nevermind. Sorry I got confused. Obviously you can make different log
> categories use the same Appender!
>
> That would be a temporary solution, as architecturally speaking we would be
> overloading the log4j with an awful amount of loggers, which I am not happy
> doing.
>
> Do you think it is feasible to achieve this by extending the Logger class
> and using it as a processor? What method would I have to override? Any
> special considerations? I think I may attempt to do this...

I'm not quite sure I follow. Claus's example uses a single Logger
called "ValidatingAgainstXMLSchema" or whatever. i.e. you can use a
single Logger if you want - the URI log:foo defines the logger to use.
There's not one per message or anything like that. Each different log
URI uses a different logger, so its up to you to define how many
different logger/categories you want to use.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

RE: Custom log messages

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Created a ticket for the request:
CAMEL-908

https://issues.apache.org/activemq/browse/CAMEL-908


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
Sent: 16. september 2008 12:22
To: camel-user@activemq.apache.org
Subject: RE: Custom log messages



Nevermind. Sorry I got confused. Obviously you can make different log
categories use the same Appender!

That would be a temporary solution, as architecturally speaking we would be
overloading the log4j with an awful amount of loggers, which I am not happy
doing.

Do you think it is feasible to achieve this by extending the Logger class
and using it as a processor? What method would I have to override? Any
special considerations? I think I may attempt to do this...

Raul.



raulvk.soa wrote:
> 
> 
> Claus Ibsen wrote:
>> 
>> to("log:ValidatingAgainstXMLSchema")
>> to("log:ValidationOK")
>> 
> 
> But wouldn't this imply that each message is printed on a different log
> file (the one associated with the logging category)?
> 
> Raul.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Custom-log-messages-tp19508418s22882p19509077.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Custom log messages

Posted by "raulvk.soa" <ra...@gmail.com>.

Nevermind. Sorry I got confused. Obviously you can make different log
categories use the same Appender!

That would be a temporary solution, as architecturally speaking we would be
overloading the log4j with an awful amount of loggers, which I am not happy
doing.

Do you think it is feasible to achieve this by extending the Logger class
and using it as a processor? What method would I have to override? Any
special considerations? I think I may attempt to do this...

Raul.



raulvk.soa wrote:
> 
> 
> Claus Ibsen wrote:
>> 
>> to("log:ValidatingAgainstXMLSchema")
>> to("log:ValidationOK")
>> 
> 
> But wouldn't this imply that each message is printed on a different log
> file (the one associated with the logging category)?
> 
> Raul.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Custom-log-messages-tp19508418s22882p19509077.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Custom log messages

Posted by "raulvk.soa" <ra...@gmail.com>.

Claus Ibsen wrote:
> 
> to("log:ValidatingAgainstXMLSchema")
> to("log:ValidationOK")
> 

But wouldn't this imply that each message is printed on a different log file
(the one associated with the logging category)?

Raul.


-- 
View this message in context: http://www.nabble.com/Custom-log-messages-tp19508418s22882p19508896.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Custom log messages

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

Ah nice idea. No currently not to set on the log endpoint URI (eg: "log:info?human=Hello this is me"


As a work around you can add these human readable texts to the message as either a header or properties.

From("xxx").setHeader("human", constant("Hello World")).to("log:xxx")

Or you could use the log category for human readable, but I guess you can not use spaces

to("log:ValidatingAgainstXMLSchema")
to("log:ValidationOK")

etc.

But I guess the option to set a URI option on the log itself is nice. If you need it please file a JIRA and we will get it in Camel 1.5




Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
Sent: 16. september 2008 11:46
To: camel-user@activemq.apache.org
Subject: RE: Custom log messages


Hi Claus,

My requirement is a bit different... I need to print human-readable messages
such as "Validating against XML Schema...", "Validation OK", "Validation
ERROR", etc... Therefore, I need to be able to specify the message that
should be printed out when I am building the route.

Don't know if I have expressed myself clearly...

Is there any functionality in Camel that will allow me to do send custom log
messages to the Log component?

Thanks.



Claus Ibsen wrote:
> 
> Hi
> 
> You can use tracer for tracing the flow of messages. And in what sequence
> it is:
> http://activemq.apache.org/camel/tracer.html
> 
> And feedback of this one is welcome. We have a request to be able to log
> the "from" node also, so you know the previous step.
> 
> 
> The log component itself can be customized its log format:
> http://activemq.apache.org/camel/log.html
> But it doesn't support the "destination node" as the tracer does.
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
> Sent: 16. september 2008 11:33
> To: camel-user@activemq.apache.org
> Subject: Custom log messages
> 
> 
> Hi,
> 
> Is there any possibility to print custom log lines on log files? For
> example, via de "log:" component?
> 
> My requirement is to print out not only the contents and the attributes of
> the message, but also a line describing in which point of the processing
> sequence the message actually is.
> 
> Thanks.
> 
> -- 
> View this message in context:
> http://www.nabble.com/Custom-log-messages-tp19508418s22882p19508418.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Custom-log-messages-tp19508418s22882p19508601.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Custom log messages

Posted by "raulvk.soa" <ra...@gmail.com>.
Hi Claus,

My requirement is a bit different... I need to print human-readable messages
such as "Validating against XML Schema...", "Validation OK", "Validation
ERROR", etc... Therefore, I need to be able to specify the message that
should be printed out when I am building the route.

Don't know if I have expressed myself clearly...

Is there any functionality in Camel that will allow me to do send custom log
messages to the Log component?

Thanks.



Claus Ibsen wrote:
> 
> Hi
> 
> You can use tracer for tracing the flow of messages. And in what sequence
> it is:
> http://activemq.apache.org/camel/tracer.html
> 
> And feedback of this one is welcome. We have a request to be able to log
> the "from" node also, so you know the previous step.
> 
> 
> The log component itself can be customized its log format:
> http://activemq.apache.org/camel/log.html
> But it doesn't support the "destination node" as the tracer does.
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
> Sent: 16. september 2008 11:33
> To: camel-user@activemq.apache.org
> Subject: Custom log messages
> 
> 
> Hi,
> 
> Is there any possibility to print custom log lines on log files? For
> example, via de "log:" component?
> 
> My requirement is to print out not only the contents and the attributes of
> the message, but also a line describing in which point of the processing
> sequence the message actually is.
> 
> Thanks.
> 
> -- 
> View this message in context:
> http://www.nabble.com/Custom-log-messages-tp19508418s22882p19508418.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Custom-log-messages-tp19508418s22882p19508601.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Custom log messages

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

You can use tracer for tracing the flow of messages. And in what sequence it is:
http://activemq.apache.org/camel/tracer.html

And feedback of this one is welcome. We have a request to be able to log the "from" node also, so you know the previous step.


The log component itself can be customized its log format:
http://activemq.apache.org/camel/log.html
But it doesn't support the "destination node" as the tracer does.



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
Sent: 16. september 2008 11:33
To: camel-user@activemq.apache.org
Subject: Custom log messages


Hi,

Is there any possibility to print custom log lines on log files? For
example, via de "log:" component?

My requirement is to print out not only the contents and the attributes of
the message, but also a line describing in which point of the processing
sequence the message actually is.

Thanks.

-- 
View this message in context: http://www.nabble.com/Custom-log-messages-tp19508418s22882p19508418.html
Sent from the Camel - Users mailing list archive at Nabble.com.