View Javadoc

    1   /*
    2    * This file is part of dependency-check-core.
    3    *
    4    * Dependency-check-core is free software: you can redistribute it and/or modify it
    5    * under the terms of the GNU General Public License as published by the Free
    6    * Software Foundation, either version 3 of the License, or (at your option) any
    7    * later version.
    8    *
    9    * Dependency-check-core is distributed in the hope that it will be useful, but
    10   * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11   * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    12   * details.
    13   *
    14   * You should have received a copy of the GNU General Public License along with
    15   * dependency-check-core. If not, see http://www.gnu.org/licenses/.
    16   *
    17   * Copyright (c) 2013 Jeremy Long. All Rights Reserved.
    18   */
    19  package org.owasp.dependencycheck.utils;
    20
    21  import java.util.logging.Filter;
    22  import java.util.logging.LogRecord;
    23
    24  /**
    25   * A simple log filter to limit the entries written to the verbose log file. The
    26   * verbose log file uses the root logger as I couldn't get anything else to
    27   * work; as such, this filter limits the log entries to specific classes.
    28   *
    29   * @author Jeremy Long (jeremy.long@owasp.org)
    30   */
    31  public class LogFilter implements Filter {
    32
    33      /**
    34       * Determines if the record should be logged.
    35       *
    36       * @param record a log record to examine
    37       * @return true if the record should be logged, otherwise false
    38       */
    39      @Override
    40      public boolean isLoggable(LogRecord record) {
    41          final String name = record.getSourceClassName();
    42          return name.startsWith("org.owasp.dependencycheck") && !name.contains("generated") && !name.contains("VelocityLoggerRedirect");
    43      }
    44  }