camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Custom log messages
Date Tue, 16 Sep 2008 10:31:41 GMT
2008/9/16 raulvk.soa <raulvk.soa@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

Mime
View raw message