Author |
Message
|
Pratik611 |
Posted: Wed Mar 11, 2015 2:43 am Post subject: Logging Strings |
|
|
Novice
Joined: 27 Jul 2014 Posts: 17
|
Hi Guys,
Wanted to know weather storing strings in multiple environment variables is better than concatenating it all in one variable?
Both these variables will be used for logging using a Trace node! |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 11, 2015 4:39 am Post subject: Re: Logging Strings |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Pratik611 wrote: |
Wanted to know weather storing strings in multiple environment variables is better than concatenating it all in one variable? |
They're both equally bad.
Pratik611 wrote: |
Both these variables will be used for logging using a Trace node! |
and that's worse.
Use Trace nodes for tracing. Don't use them for logging. Use something better and more effecient (i.e. anything). _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Mar 11, 2015 5:38 am Post subject: Re: Logging Strings |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Pratik611 wrote: |
Both these variables will be used for logging using a Trace node! |
Back in the days of V2.0.2 & V2.1 Trace nodes were just about all that we had. Now the situation is very different.
There are many solutions for logging including 'Log4J' (shudder, no please no, not Log4j, anything but Log4J.)
It all comes down to what you want to log.
Any well established project will have a well established logging framework that makes life easy.
Think very seriously about logging to files. Think how it might be used in production? how big will they get? What about logfile rotation? etc etc etc etc.
A good few of us here write log/audit/error events to DB tables. Then a batch job can run to purge the old stuff. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 11, 2015 6:07 am Post subject: Re: Logging Strings |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
smdavies99 wrote: |
There are many solutions for logging including 'Log4J' (shudder, no please no, not Log4j, anything but Log4J.) |
Log4j is better Than a trace node.
Javax.util.logging is better than log4j (the Java people tell me).
DB tables are cool.
etc. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Mar 11, 2015 6:07 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
If you need to access the fields individually, you should store them as separate variables.
If you only ever need to access them collectively, you should store them as a single value, concatenated.
The only reason to really sweat the difference between these is if you are optimizing your code to seven decimal points... and then you've already wasted your time optimizing to 5 decimal points, so you might as well give up.
Otherwise. Don't use trace nodes for logging!
If for no other reason than that a trace node keeps an exclusive lock on the file it's writing to, so that you have to go in and muck with the actual contents to shrink the file without stopping the flow...
And don't use log4j. Use java.util.logging, if you really want to do logging from Java in IIB. |
|
Back to top |
|
 |
joebuckeye |
Posted: Wed Mar 11, 2015 8:39 am Post subject: |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
mqjeff wrote: |
If for no other reason than that a trace node keeps an exclusive lock on the file it's writing to, so that you have to go in and muck with the actual contents to shrink the file without stopping the flow... |
An easy way to "deal" with trace files is to do a "cp /dev/null <trace file>". That zeroes the file out without causing the node to "lose" the file.
Of course we only use trace nodes for debugging while developing and not as any part of a production logging solution. |
|
Back to top |
|
 |
|