Separate logs for each order in Log4J

In my current project we are using Apache CommonsLogging backed up by Log4J.

Though it is a Multi-threaded application (processes multiple orders simultaneously), all the logs from all these threads simultaneously go inside a single file (via RollingFileAppender). Recently there was a change request to maintain separate logs for each order.
Having a separate file for every incoming order can prove a little more than costly.

— Housekeeping of these logs on the basis of time? Who decides which log has to be kept and which one has to be discarded? Perhaps it can be handled by writing a few shellscripts.

— Under development, or in production, for each run we’d have to open a different Log file to check the Logs for debugging purposes.

— On a Unix server there is a limited number of inodes or files that you can keep inside a directory. You run out of it then you cannot create more files and for such a bulky directory, manipulation would be a big pain.
So I would rather append an identifier (which can tell the order uniquely) with each and every log statement and then can easily `grep` the main Log file for the complete logs of a particular order.

— Appending ORDERID of that order to each and every log statement of a big big application would be a major overhead and isn’t maintainable. What if there comes a NEWUNIQUEVALUE for the orders!?

— Appending ORDERID just to the first and the last log statement wouldn’t guarantee that all the logs which get extracted are of that same order. It is a multi-threaded application anyway.


Make changes to the file. Add a %t at the starting of the Pattern.


ConversionPattern=%p %c – %m%n


ConversionPattern=%t %p %c – %m%n

(Here we are asking the Logging Framework to append the name of the Thread to the logs)

t = Used to output the name of the thread that generated the logging event.

p = Used to output the priority of the logging event.

c = Used to output the category of the logging event.

m = Used to output the application supplied message associated with the logging event.

n = Outputs the platform dependent line separator character or characters.


In your Java code, inside the run() method of the ThreadClass or the Concrete Implementation of the Runnable Interface change the name of the Thread using:

String uniqueOrderId = ${ fetched from inside the order XML etc };


If for some reason you need to preserve the ThreadName, in that case append it back to the uniqueOrderId.


$ grep uniqueOrderId MAINLOG.log > uniqueOrderId.log

(find the lines with uniqueOrderId in the MAINLOG.log and create a new file uniqueOrderId.log with that)


(Dinner is getting cold. I know I could have been more verbose! TING!)

Make the most *out of the*

A Google Account:

Premise: For a Google Account (not the Google Apps account), the dots do not matter.

Yeah that’s correct. So if your Google ID is “” Try logging in with “” or try sending and email to this brand new email id. It works seamlessly. Thanks Google. It is confusing for lesser mortals (wink). Get over it!

The Biggest Use: You can have different email IDs for Work, Home, others. And still manage everything at the same place.

Say on a website which you do not trust completely (they might send you SPAM… BAM!), you can list an email ID as “” and create a “sent-to:” filter on your GMail. You are saved!

Work related emails will go to:

Friends’ emails will go under a different label:

(and just to complicate things further, is ALLOWED too. Think of “work” as a label. Create a filter on the “sent-to” and move to a label “work” and “skip-inbox”. Ah! Give me a break!! I am not going to show you how to create a filter now!

Word of caution: not every website would accept a plus symbol in a valid email address)

Trivia: Also, there was this smart guy in my college (I mean one of the SMART smart ones). He was kind of showing-off (his know how) and asked me to capital-case [verb] the email ID because he made it that way! Don’t be too sensitive when I say this but the email IDs are NOT case-sensitive (generally?). Though user-names are (eg: But URLs are (generally) NOT!. Though on resource links, the case matters… hehe)! and there are Passwords. (ting)




Then there is Box…..

A Box Account: (redirects to) —, provides simple online collaboration: Online File Storage, FTP Replacement, Team Workspaces. You can create a free account. You get a free 5GB account (much like Google Drive or what DropBox gives you after much ado)!

But as a promotional offer, if you login to the Box for Android App on an LG device or Xperia S etc (until the end of 2012 [well yeah that is assuming it is going to come]), your basic account will be upgraded to a 50GB-for-life-account.

I like box for a lot of other reasons (I mean not just the ginormous 50GB, or the reason of this blog post):

— It gives me a place to comment/discuss each file separately.

— Supported on a variety of devices

— Instant email notifications of activities

— It lets me collaborate with people very easily.



Coming to the point NOW…. Finally…

Yes Collaboration is fun:

So I was wondering if I could create another BOX account ( and then Share a folder (xyz) with my main account ( then in all I would have 50 * 2 = 100 GBs of storage. Upload all the stuff in (xyz). How cool is that!? But it’s a little messy. Yes here the first part of the blog comes into the picture. Fits “Seamlessly” (I just love the word. Don’t I?)! 😛

Take a moment and think about it. Check the Screenshots below! Cheers mate! 😀


image has created a new box account!


Ten.Second.Tom: a folder created, & shared with to keep track of all the other accounts like (wink)


Next Step: Login to the Box for Android on an LG device or Xperia S 😀 and get 50Gb free for life!



— Is there a limit on how much can you upload to someone’s shared folder?

Well even if there is… I can always login to the other account and upload to the shared folder. I do not have to always upload through my main account.

— Will, at some point, realize this after reading my blog (yeah I know they know it already!) and think about deactivating my other or all accounts?? Not Fair!! I think it shouldn’t matter to Box. What do you think?

— I think keeping your pictures and videos HDD-crash proof is a good idea. But I might not do it. There has to be an extent to how much and what all you can keep on the Internet.