@@ -0,0 +1,1994 @@
+package org.ovirt.engine.core.utils.log;%0A%0Aimport java.io.IOException;%0Aimport java.net.URL;%0A%0Aimport javax.xml.parsers.FactoryConfigurationError;%0A%0Aimport org.apache.log4j.FileAppender;%0Aimport org.apache.log4j.Level;%0Aimport org.apache.log4j.LogManager;%0Aimport org.apache.log4j.Logger;%0Aimport org.apache.log4j.PatternLayout;%0Aimport org.apache.log4j.xml.DOMConfigurator;%0A%0A/**%0A * Contains methods for runtime log4j setup%0A */%0Apublic class Log4jUtils %7B%0A    /**%0A     * Resets logging configuration and tries to configure logging using specified configuration.%0A     *%0A     * @param url%0A     *            URL with log4j.xml%0A     */%0A    public static void setupLogging(URL url) %7B%0A        try %7B%0A            LogManager.resetConfiguration();%0A            DOMConfigurator.configure(url);%0A        %7D catch (FactoryConfigurationError ex) %7B%0A            throw new RuntimeException(%22Cannot configure logging: %22 + ex.getMessage(), ex);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Adds file appender with specified file and log level to root logger%0A     *%0A     * @param fileName%0A     *            file name to log into%0A     * @param levelName%0A     *            log level to use%0A     */%0A    public static void addFileAppender(String fileName, String levelName) %7B%0A        try %7B%0A            Level level = Level.INFO;%0A            if (levelName != null) %7B%0A                level = Level.toLevel(levelName, null);%0A                if (level == null) %7B%0A                    throw new IllegalArgumentException(String.format(%22Invalid log level value: '%25s'%22, levelName));%0A                %7D%0A            %7D%0A%0A            FileAppender fa = new FileAppender(new PatternLayout(%22%25d %25-5p %5B%25c%5D %25m%25n%22), fileName, true);%0A            fa.setThreshold(level);%0A            Logger.getRootLogger().addAppender(fa);%0A        %7D catch (SecurityException %7C IOException ex) %7B%0A            throw new IllegalArgumentException(%0A                    String.format(%22Error accessing log file '%25s': '%25s'%22, fileName, ex.getMessage()),%0A                    ex);%0A        %7D%0A    %7D%0A%7D%0A

Add common methods for runtime log4j setup