Changes for page Wonder Logging

Last modified by Maik Musall on 2021/12/13 12:44

From version 5.1
edited by Johann Werner
on 2016/01/15 04:33
Change comment: add a best practices paragraph
To version 7.1
edited by Johann Werner
on 2014/01/14 11:10
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -Wonder Logging
1 +Kopie von Wonder Logging
Content
... ... @@ -3,9 +3,9 @@
3 3  === Logging Framework ===
4 4  
5 5  SLF4J
6 -[[http:~~/~~/www.slf4j.org/>>url:http://www.slf4j.org/||style="text-decoration: none;" shape="rect"]]
6 +[[http:~~/~~/www.slf4j.org/ >>url:http://www.slf4j.org/||style="text-decoration: none;" shape="rect"]]
7 7  
8 -=== Needed Frameworks ===
8 +=== [[Needed Frameworks>>url:http://www.slf4j.org/||style="text-decoration: none;" shape="rect"]] ===
9 9  
10 10  slf4j-api-1.7.5.jar
11 11  slf4j-log4j12-1.7.5.jar
... ... @@ -62,8 +62,10 @@
62 62  }
63 63  {{/code}}
64 64  
65 -(% class="Apple-style-span" style="white-space: pre-wrap;" %) (%%)Of course you still can use parameters as long as the exception is the last param:
65 +(% class="Apple-style-span" style="white-space: pre-wrap;" %)
66 66  
67 +Of course you still can use parameters as long as the exception is the last param:
68 +
67 67  {{code language="java"}}
68 68  try {
69 69   …
... ... @@ -72,19 +72,6 @@
72 72  }
73 73  {{/code}}
74 74  
75 -=== Best Practices ===
76 -
77 -Logging normally takes not part of the public API of a class and thus should be kept internally. So your class should neither use class-external logger objects nor provide own logger objects to other classes but declare them in private variables instead. Best practice is to create a logger that way:
78 -
79 -{{code language="java"}}
80 -class MyClass {
81 - private static final Logger log = LoggerFactory.getLogger(MyClass.class);
82 - …
83 -}
84 -{{/code}}
85 -
86 -If you want to use a logger associated to another class you can pass that class to the getLogger method. Logger objects are cached so you won't create multiple instances of logger objects for the same class.
87 -
88 88  === More SLF4J info ===
89 89  
90 90  (% class="Apple-style-span" style="white-space: pre-wrap;" %)For more info regarding SLF4J look at the introductory [[user manual>>url:http://www.slf4j.org/manual.html||shape="rect"]] or head to their [[documentation page>>url:http://www.slf4j.org/docs.html||shape="rect"]].