Package org.apache.log4j

Examples of org.apache.log4j.Category


     * @param data The object to log.
     * @param channel The channel name used for logging.
     * @param level The level used for logging.
     */
    public void log(Object data, String channel, int level) {
        Category cat = getCategory(channel);
    if (data instanceof Throwable)
            cat.log(toPriority(level), data, (Throwable)data);
        else 
            cat.log(toPriority(level), data);
    }
View Full Code Here


     * @param channel The channel specification
     * @param level   The level specification
     */

    public boolean isEnabled(String channel, int level) {
        Category cat = getCategory(channel);
        return cat.isEnabledFor(toPriority(level));
    }
View Full Code Here

   
   
    // ------------------------------------------------------ Private/Protected Methods
   
    private Category getCategory(String channel) {
        Category cat = Category.exists(channel);
        if (cat == null) {
            cat = Category.getInstance(channel);
        }
        return cat;
    }
View Full Code Here

      }
      long ts = cal.getTimeInMillis();
      // If this event is not between the start and end dates, then skip it.
      if (null != dateFilter && !dateFilter.containsLong(ts))
        return null;
      Category c = Logger.getLogger(clazz);
      Level l = Level.toLevel(level);
      LoggingEvent event = new LoggingEvent(clazz, c, ts, l, message, threadName, (ThrowableInformation) null, (String) null, (LocationInfo) null,
          (Map<?,?>) null);
      // Check the log level filter
      if (null != levelFilter && (levelFilter.decide(event) == Filter.DENY)) {
View Full Code Here

    /**
     * Construct the listener and make sure there is a valid appender.
     */
    public Log4jListener() {
        initialized = false;
        Category cat = Category.getInstance("org.apache.tools.ant");
        Category rootCat = Category.getRoot();
        if (!(rootCat.getAllAppenders() instanceof NullEnumeration)) {
            initialized = true;
        } else {
            cat.error("No log4j.properties in build area");
        }
    }
View Full Code Here

    /**
     * @see BuildListener#buildStarted
     */
    public void buildStarted(BuildEvent event) {
        if (initialized) {
            Category cat = Category.getInstance(Project.class.getName());
            cat.info("Build started.");
        }
    }
View Full Code Here

    /**
     * @see BuildListener#buildFinished
     */
    public void buildFinished(BuildEvent event) {
        if (initialized) {
            Category cat = Category.getInstance(Project.class.getName());
            if (event.getException() == null) {
                cat.info("Build finished.");
            } else {
                cat.error("Build finished with error.", event.getException());
            }
        }
    }
View Full Code Here

    /**
     * @see BuildListener#targetStarted
     */
    public void targetStarted(BuildEvent event) {
        if (initialized) {
            Category cat = Category.getInstance(Target.class.getName());
            cat.info("Target \"" + event.getTarget().getName() + "\" started.");
        }
    }
View Full Code Here

     * @see BuildListener#targetFinished
     */
    public void targetFinished(BuildEvent event) {
        if (initialized) {
            String targetName = event.getTarget().getName();
            Category cat = Category.getInstance(Target.class.getName());
            if (event.getException() == null) {
                cat.info("Target \"" + targetName + "\" finished.");
            } else {
                cat.error("Target \"" + targetName
                    + "\" finished with error.", event.getException());
            }
        }
    }
View Full Code Here

     * @see BuildListener#taskStarted
     */
    public void taskStarted(BuildEvent event) {
        if (initialized) {
            Task task = event.getTask();
            Category cat = Category.getInstance(task.getClass().getName());
            cat.info("Task \"" + task.getTaskName() + "\" started.");
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.log4j.Category

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.