Unterschiede
Hier werden die Unterschiede zwischen der gewählten und der aktuellen Version gezeigt.
java:logging 2009/11/04 10:50 | java:logging 2020/01/22 20:59 aktuell | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | [[java|Java - Allgemein]]\\ | ||
====== Java Logging ====== | ====== Java Logging ====== | ||
Fürs Erste soll das einfache Beispiel eines Logging auf die Console reichen:\\ | Fürs Erste soll das einfache Beispiel eines Logging auf die Console reichen:\\ | ||
- | \\ | ||
- | <html> | ||
- | <script type="text/javascript"><!-- | ||
- | google_ad_client="pub-9681858985507948"; | ||
- | google_ad_width = 468; | ||
- | google_ad_height = 60; | ||
- | google_ad_format = "468x60_as"; | ||
- | google_ad_type = "text"; | ||
- | google_ad_channel = ""; | ||
- | google_color_border = "cccccc"; | ||
- | google_color_bg = "FFFFFF"; | ||
- | google_color_link = "1d2d8c"; | ||
- | google_color_text = "000000"; | ||
- | google_color_url = "1d2d8c"; | ||
- | //--> | ||
- | </script> | ||
- | <script type="text/javascript" | ||
- | src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> | ||
- | </script> | ||
- | </html> | ||
- | \\ | ||
<code java> | <code java> | ||
import java.util.logging.*; | import java.util.logging.*; | ||
Zeile 43: | Zeile 23: | ||
} | } | ||
</code> | </code> | ||
+ | \\ | ||
+ | <html> | ||
+ | <script type="text/javascript"><!-- | ||
+ | google_ad_client="pub-9681858985507948"; | ||
+ | google_ad_width = 468; | ||
+ | google_ad_height = 60; | ||
+ | google_ad_format = "468x60_as"; | ||
+ | google_ad_type = "text"; | ||
+ | google_ad_channel = ""; | ||
+ | google_color_border = "cccccc"; | ||
+ | google_color_bg = "FFFFFF"; | ||
+ | google_color_link = "1d2d8c"; | ||
+ | google_color_text = "000000"; | ||
+ | google_color_url = "1d2d8c"; | ||
+ | //--> | ||
+ | </script> | ||
+ | <script type="text/javascript" | ||
+ | src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> | ||
+ | </script> | ||
+ | </html> | ||
+ | \\ | ||
\\ | \\ | ||
Das Logging kann auch über eine Datei //logging.properties// gesteuert werden.\\ | Das Logging kann auch über eine Datei //logging.properties// gesteuert werden.\\ | ||
Festlegen, von wo die Datei geladen werden soll:\\ | Festlegen, von wo die Datei geladen werden soll:\\ | ||
<code java> | <code java> | ||
- | try{ | + | try { |
String strLogPath = "/log/logging.properties"; // Ort von logging.properties festlegen | String strLogPath = "/log/logging.properties"; // Ort von logging.properties festlegen | ||
File fileLog = new File(strLogPath); | File fileLog = new File(strLogPath); | ||
Zeile 75: | Zeile 76: | ||
java.util.logging.FileHandler.pattern = MyApplication.log | java.util.logging.FileHandler.pattern = MyApplication.log | ||
</code> | </code> | ||
+ | \\ | ||
+ | Auch der Stacktrace lässt sich loggen:\\ | ||
+ | <code java> | ||
+ | LOGGER.log(Level.SEVERE, "Message", e); | ||
+ | </code> | ||
+ | |||
+ | Es gibt folgende Methoden zum Loggen:\\ | ||
+ | severe(msg)\\ | ||
+ | warning(msg)\\ | ||
+ | info(msg)\\ | ||
+ | config(msg)\\ | ||
+ | fine(msg)\\ | ||
+ | finer(msg)\\ | ||
+ | finest(msg) | ||
+ | |||
+ | |||
+ | |||
- | Wird ergänzt... |