This is what I found in log4j FAQ for my question. This is exactly my problem and the last solution provided is what would work for me. But in order to do this, I think ( I am not sure) there might be some code change necessary within Hibernate Source code
3.1 Can the outputs of multiple client request go to different log files?
Many developers are confronted with the problem of distinguishing the log output originating from the same class but different client requests. They come up with ingenious mechanisms to fan out the log output to different files. In most cases, this is not the right approach.
It is simpler to use a nested diagnostic context (NDC). Typically, one would NDC.push() client specific information, such as the client's hostname, ID or any other distinguishing information when starting to handle the client's request. Thereafter, log output will automatically include the nested diagnostic context so that you can distinguish logs from different client requests even if they are output to the same file.
See the NDC and the PatternLayout classes for more information. The NumberCruncher example shows how the NDC can be used to distinguish the log output from multiple clients even if they share the same log file.
[b]For select applications, such as virtual hosting web-servers, the NDC solution is not sufficient. As of version 0.9.0, log4j supports multiple hierarchy trees. Thus, it is possible to log to different targets from the same logger depending on the current context[/b].
|