<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Cambria;
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.E-MailFormatvorlage17
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.E-MailFormatvorlage18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page Section1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=DE-CH link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-family:"Cambria","serif"'>Hi all,<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-family:"Cambria","serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'>I
have a little question how to use slf4j correctly.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'>We
use SLF4J as logging frontend in a framework.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'>There
are lots of classes that contain business logic. These classes are initialized
once.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'>Here
we have the following signature for the loggers “private final Logger
logger = LoggerFactory.getLogger(MyClass.class);“.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'>On
the other hand there are a lot of domain classes. In a productive environment
it is possible that there are 10'000 or 100’000s of domain classes.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'>The
domain classes also have to log stuff. I think there it won’t be a good idea to
have the logger static.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-family:"Cambria","serif"'>But then the
drawbacks of static occur (not ioc friendly, unknown behavior because the
logger is JVM wide the same).<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-family:"Cambria","serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-family:"Cambria","serif"'>We thought about
the following solution but are not sure if SLF4J can be used like that :<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-family:"Cambria","serif"'>All
business-logic classes that are </span><span lang=EN-US style='font-family:
"Cambria","serif"'>initialized</span><span style='font-family:"Cambria","serif"'>
once get the logger like written above :“private final Logger logger =
LoggerFactory.getLogger(MyClass.class);“.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'>The
domain classes are created through a factory. In this factory we have a call
like “private final Logger logger =
MySingletonLoggerFactory.getLogger(MyDomainClass.class) ;“<o:p></o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'>The
MySingletonLoggerFactory class then is responsible of returning the same logger
for each type of domain object.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'>What
do you think about the solution?<o:p></o:p></span></p>
<p class=MsoNormal><span lang=FR-CH style='font-family:"Cambria","serif"'>Is
this a feasible way ? </span><span style='font-family:"Cambria","serif"'>Are
there better ways to go?<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-family:"Cambria","serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-family:"Cambria","serif"'>I am really
looking forward to hearing from you.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-family:"Cambria","serif"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-family:"Cambria","serif"'>Regards,<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-family:"Cambria","serif"'>Florian<o:p></o:p></span></p>
</div>
</body>
</html>