View Javadoc
1 package org.apache.turbine.services.logging; 2 3 /* ==================================================================== 4 * The Apache Software License, Version 1.1 5 * 6 * Copyright (c) 2001 The Apache Software Foundation. All rights 7 * reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in 18 * the documentation and/or other materials provided with the 19 * distribution. 20 * 21 * 3. The end-user documentation included with the redistribution, 22 * if any, must include the following acknowledgment: 23 * "This product includes software developed by the 24 * Apache Software Foundation (http://www.apache.org/)." 25 * Alternately, this acknowledgment may appear in the software itself, 26 * if and wherever such third-party acknowledgments normally appear. 27 * 28 * 4. The names "Apache" and "Apache Software Foundation" and 29 * "Apache Turbine" must not be used to endorse or promote products 30 * derived from this software without prior written permission. For 31 * written permission, please contact apache@apache.org. 32 * 33 * 5. Products derived from this software may not be called "Apache", 34 * "Apache Turbine", nor may "Apache" appear in their name, without 35 * prior written permission of the Apache Software Foundation. 36 * 37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 39 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 40 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 44 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 48 * SUCH DAMAGE. 49 * ==================================================================== 50 * 51 * This software consists of voluntary contributions made by many 52 * individuals on behalf of the Apache Software Foundation. For more 53 * information on the Apache Software Foundation, please see 54 * <http://www.apache.org/>;. 55 */ 56 57 import javax.servlet.ServletConfig; 58 import org.apache.turbine.services.InitializationException; 59 import org.apache.turbine.util.RunData; 60 61 /*** 62 * This service functions as a simple logger provider (with only one logger). 63 * It needs no configuration file because all messages are printed 64 * using servlet log method. 65 * 66 * @see org.apache.turbine.services.logging.Logger 67 * @author <a href="mailto:Tomasz.Zielinski@e-point.pl">Tomasz Zielinski</a> 68 * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a> 69 * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a> 70 * @version $Id: ServletLoggingService.java,v 1.2 2002/07/11 16:53:26 mpoeschl Exp $ 71 */ 72 public class ServletLoggingService 73 extends TurbineLoggingService 74 { 75 /*** 76 * Inits the service 77 */ 78 public void init(ServletConfig config) throws InitializationException 79 { 80 if (getInit()) 81 { 82 return; 83 } 84 85 if (config!=null) 86 { 87 defaultLogger = new ServletLogger(); 88 89 LoggingConfig lc = getLoggingConfig(); 90 lc.setName(LoggingConfig.DEFAULT); 91 lc.setInitResource(null); 92 lc.setServletContext(config.getServletContext()); 93 lc.init(); 94 95 defaultLogger.init(lc); 96 setInit(true); 97 System.out.println("Starting Servlet Logging Service"); 98 } 99 else 100 { 101 System.out.println("Servlet Logging Service - Failed to Start!" + 102 " Config == Null"); 103 } 104 } 105 106 /*** 107 * This method returns default logger, ignoring given name. 108 */ 109 public Logger getLogger(String logName) 110 { 111 return getLogger(); 112 } 113 114 /*** 115 * This method sets the log level in default logger 116 */ 117 public void setLogLevel(int level) 118 { 119 getLogger().setLogLevel(level); 120 } 121 122 /*** 123 * This method sets the log level in the default logger ignoring given name 124 */ 125 public void setLogLevel(String logName, int level) 126 { 127 getLogger().setLogLevel(level); 128 } 129 130 /*** 131 * This method sets format style of the default logger 132 */ 133 public void setFormat(String format) 134 { 135 getLogger().setFormat(format); 136 } 137 138 /*** 139 * This method sets format style of the given logger. 140 */ 141 public void setFormat(String logName, String format) 142 { 143 getLogger().setFormat(format); 144 } 145 146 /*** 147 * This is a log method with logLevel == DEBUG, printing is done by 148 * the default logger 149 */ 150 public void debug(String message) 151 { 152 getLogger().debug(message); 153 } 154 155 /*** 156 * This is a log method with logLevel == DEBUG, printing is done by 157 * the default logger 158 */ 159 public void debug(String message, Throwable t) 160 { 161 getLogger().debug(message, t); 162 } 163 164 /*** 165 * This is a log method with logLevel == DEBUG, printing is done by 166 * the given logger 167 */ 168 public void debug(String logName, String message, Throwable t) 169 { 170 getLogger().debug(message, t); 171 } 172 173 /*** 174 * This is a log method with logLevel == DEBUG, printing is done by 175 * the given logger 176 */ 177 public void debug(String logName, String message) 178 { 179 getLogger().debug(message); 180 } 181 182 /*** 183 * This is a log method with logLevel == DEBUG, printing is done by 184 * the default logger 185 */ 186 public void debug(String message, RunData data) 187 { 188 getLogger().debug(message, data); 189 } 190 191 /*** 192 * This is a log method with logLevel == DEBUG, printing is done by 193 * the default logger 194 */ 195 public void debug(String message, RunData data, Throwable t) 196 { 197 getLogger().debug(message, data, t); 198 } 199 200 /*** 201 * This is a log method with logLevel == DEBUG, printing is done by 202 * the given logger 203 */ 204 public void debug(String logName, String message, RunData data, Throwable t) 205 { 206 getLogger().debug(message, data, t); 207 } 208 209 /*** 210 * This is a log method with logLevel == DEBUG, printing is done by 211 * the given logger 212 */ 213 public void debug(String logName, String message, RunData data) 214 { 215 getLogger().debug(message, data); 216 } 217 218 /*** 219 * This is a log method with logLevel == INFO, printing is done by 220 * the default logger 221 */ 222 public void info(String message) 223 { 224 getLogger().info(message); 225 } 226 227 /*** 228 * This is a log method with logLevel == INFO, printing is done by 229 * the default logger 230 */ 231 public void info(String message, Throwable t) 232 { 233 getLogger().info(message, t); 234 } 235 236 /*** 237 * This is a log method with logLevel == INFO, printing is done by 238 * the given logger 239 */ 240 public void info(String logName, String message) 241 { 242 getLogger().info(message); 243 } 244 245 /*** 246 * This is a log method with logLevel == INFO, printing is done by 247 * the given logger 248 */ 249 public void info(String logName, String message, Throwable t) 250 { 251 getLogger().info(message, t); 252 } 253 /*** 254 * This is a log method with logLevel == INFO, printing is done by 255 * the default logger 256 */ 257 public void info(String message, RunData data) 258 { 259 getLogger().info(message, data); 260 } 261 262 /*** 263 * This is a log method with logLevel == INFO, printing is done by 264 * the default logger 265 */ 266 public void info(String message, RunData data, Throwable t) 267 { 268 getLogger().info(message, data, t); 269 } 270 271 /*** 272 * This is a log method with logLevel == INFO, printing is done by 273 * the given logger 274 */ 275 public void info(String logName, String message, RunData data) 276 { 277 getLogger().info(message, data); 278 } 279 280 /*** 281 * This is a log method with logLevel == INFO, printing is done by 282 * the given logger 283 */ 284 public void info(String logName, String message, RunData data, Throwable t) 285 { 286 getLogger().info(message, data, t); 287 } 288 289 /*** 290 * This is a log method with logLevel == WARN, printing is done by 291 * the default logger 292 */ 293 public void warn(String message) 294 { 295 getLogger().warn(message); 296 } 297 298 /*** 299 * This is a log method with logLevel == WARN, printing is done by 300 * the default logger 301 */ 302 public void warn(String message, Throwable t) 303 { 304 getLogger().warn(message, t); 305 } 306 307 /*** 308 * This is a log method with logLevel == WARN, printing is done by 309 * the given logger 310 */ 311 public void warn(String logName, String message) 312 { 313 getLogger().warn(message); 314 } 315 316 /*** 317 * This is a log method with logLevel == WARN, printing is done by 318 * the given logger 319 */ 320 public void warn(String logName, String message, Throwable t) 321 { 322 getLogger().warn(message, t); 323 } 324 325 /*** 326 * This is a log method with logLevel == WARN, printing is done by 327 * the default logger 328 */ 329 public void warn(String message, RunData data) 330 { 331 getLogger().warn(message, data); 332 } 333 334 /*** 335 * This is a log method with logLevel == WARN, printing is done by 336 * the default logger 337 */ 338 public void warn(String message, RunData data, Throwable t) 339 { 340 getLogger().warn(message, data, t); 341 } 342 343 /*** 344 * This is a log method with logLevel == WARN, printing is done by 345 * the given logger 346 */ 347 public void warn(String logName, String message, RunData data) 348 { 349 getLogger().warn(message, data); 350 } 351 352 /*** 353 * This is a log method with logLevel == WARN, printing is done by 354 * the given logger 355 */ 356 public void warn(String logName, String message, RunData data, Throwable t) 357 { 358 getLogger().warn(message, data, t); 359 } 360 361 /*** 362 * This is a log method with logLevel == ERROR, printing is done by 363 * the default logger 364 */ 365 public void error(String message) 366 { 367 getLogger().error(message); 368 } 369 370 /*** 371 * This is a log method with logLevel == ERROR, printing is done by 372 * the default logger 373 */ 374 public void error(String message, Throwable t) 375 { 376 getLogger().error(message, t); 377 } 378 379 /*** 380 * This is a log method with logLevel == ERROR, printing is done by 381 * the given logger 382 */ 383 public void error(String logName, String message) 384 { 385 getLogger().error(message); 386 } 387 388 /*** 389 * This is a log method with logLevel == ERROR, printing is done by 390 * the given logger 391 */ 392 public void error(String logName, String message, Throwable t) 393 { 394 getLogger().error(message, t); 395 } 396 397 /*** 398 * This is a log method with logLevel == ERROR, printing is done by 399 * the default logger 400 */ 401 public void error(String message, RunData data) 402 { 403 getLogger().error(message, data); 404 } 405 406 /*** 407 * This is a log method with logLevel == ERROR, printing is done by 408 * the default logger 409 */ 410 public void error(String message, RunData data, Throwable t) 411 { 412 getLogger().error(message, data, t); 413 } 414 415 /*** 416 * This is a log method with logLevel == ERROR, printing is done by 417 * the given logger 418 */ 419 public void error(String logName, String message, RunData data) 420 { 421 getLogger().error(message, data); 422 } 423 424 /*** 425 * This is a log method with logLevel == ERROR, printing is done by 426 * the given logger 427 */ 428 public void error(String logName, String message, RunData data, Throwable t) 429 { 430 getLogger().error(message, data, t); 431 } 432 }

This page was automatically generated by Maven