Software Programmer
asked on
Defining Logger as static and non-static variable
Hi,
Sometimes in project i see a static variable defined for logger
private final static Logger LOGGER = Logger.getLogger(Something .class);
in some cases i saw static is not being used and defined as
private final Logger LOGGER = Logger.getLogger(Something .class);
what is the difference between the two? Does it makes any difference in cluster and in non-cluster environment?
Thanks.
Sometimes in project i see a static variable defined for logger
private final static Logger LOGGER = Logger.getLogger(Something
in some cases i saw static is not being used and defined as
private final Logger LOGGER = Logger.getLogger(Something
what is the difference between the two? Does it makes any difference in cluster and in non-cluster environment?
Thanks.
It shouldn't make any notable difference. The static logger is used often simply to allow logging in the context of static methods
ASKER
If static used will it create issue in multi thread environment...
It's conceivable, though that might depend on the framework being used. If you're doing server-side logging, it's academic really, since you wouldn't use a static logger
ASKER
It is being used in the server side and saw in many projects which works in cluster environment and in a multi-threaded environment as well. So not sure how they are handling it. Do you think using static logger will cause an issue? if yes, how to use it and get rid of the multi-thread issue.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nice answers by both CEHJ and Andrea and fine with them.
ASKER
CHEJ your explanations are great..go through my remaining questions if you had time..