View Javadoc
1   /*
2    * JBoss, Home of Professional Open Source
3    * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
4    * contributors by the @authors tag. See the copyright.txt in the
5    * distribution for a full listing of individual contributors.
6    *
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * http://www.apache.org/licenses/LICENSE-2.0
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.jboss.as.quickstarts.logging;
18  
19  import org.jboss.logging.Logger;
20  
21  public class LoggingExample
22  {
23  
24      // a JBoss Logging 3 style level (FATAL, ERROR, WARN, INFO, DEBUG, TRACE), or a special level (OFF, ALL).
25      private static Logger log = Logger.getLogger(LoggingExample.class.getName());
26      static
27      {
28          logFatal();
29          logError();
30          logWarn();
31          logInfo();
32          logDebug();
33          logTrace();
34      }
35  
36      public static void logFatal()
37      {
38          if (log.isEnabled(Logger.Level.FATAL))
39          {
40              log.fatal("THIS IS A FATAL MESSAGE");
41          }
42      }
43  
44      public static void logError()
45      {
46          if (log.isEnabled(Logger.Level.ERROR))
47          {
48              log.error("THIS IS AN ERROR MESSAGE");
49          }
50      }
51  
52      public static void logWarn()
53      {
54          if (log.isEnabled(Logger.Level.WARN))
55          {
56              log.warn("THIS IS A WARNING MESSAGE");
57          }
58      }
59  
60      public static void logInfo()
61      {
62          if (log.isEnabled(Logger.Level.INFO))
63          {
64              log.info("THIS IS AN INFO MESSAGE");
65          }
66      }
67  
68      public static void logDebug()
69      {
70          if (log.isEnabled(Logger.Level.DEBUG))
71          {
72              log.debug("THIS IS A DEBUG MESSAGE");
73          }
74      }
75  
76      public static void logTrace()
77      {
78          if (log.isEnabled(Logger.Level.TRACE))
79          {
80              log.trace("THIS IS A TRACE MESSAGE");
81          }
82      }
83  }