// Path: logger-core/src/main/java/net/openhft/chronicle/logger/ChronicleLogManager.java
// public class ChronicleLogManager {
//     private ChronicleLogConfig cfg;
//     private Map<String, ChronicleLogWriter> writers;
// 
//     private ChronicleLogManager() {
//         this.cfg = ChronicleLogConfig.load();
//         this.writers = new ConcurrentHashMap<>();
//     }
// 
//     public static ChronicleLogManager getInstance() {
//         return Holder.INSTANCE;
//     }
// 
//     public ChronicleLogConfig cfg() {
//         return this.cfg;
//     }
// 
//     public void clear() {
//         for (final ChronicleLogWriter writer : writers.values()) {
//             try {
//                 writer.close();
//             } catch (IOException e) {
//             }
//         }
// 
//         writers.clear();
//     }
// 
//     public void reload() {
//         clear();
// 
//         this.cfg = ChronicleLogConfig.load();
//         this.writers = new ConcurrentHashMap<>();
//     }
// 
//     public ChronicleLogWriter getWriter(String name) {
//         if (this.cfg == null) {
//             throw new IllegalArgumentException("ChronicleLogManager is not configured");
//         }
// 
//         final String path = cfg.getString(name, ChronicleLogConfig.KEY_PATH);
//         if (path != null) {
//             // Creating a Queue takes some time. Other threads might be blocked for longer periods.
//             return writers.computeIfAbsent(path, p-> new DefaultChronicleLogWriter(newChronicle(p, name)));
//         } else {
//             throw new IllegalArgumentException(
//                     "chronicle.logger.root.path is not defined, chronicle.logger." + name + ".path is not defined"
//             );
//         }
//     }
// 
//     // *************************************************************************
//     //
//     // *************************************************************************
// 
//     private ChronicleQueue newChronicle(String path, String name) {
//         final String wireType = cfg.getString(name, ChronicleLogConfig.KEY_WIRETYPE);
//         ChronicleQueue cq = this.cfg.getAppenderConfig().build(path, wireType);
//         if (!cfg.getBoolean(name, ChronicleLogConfig.KEY_APPEND, true)) {
//             // TODO re-enable when it's implemented. ATM it throws UnsupportedOperationException...
//             //cq.clear();
//         }
//         return cq;
//     }
// 
//     // *************************************************************************
//     //
//     // *************************************************************************
// 
//     private static class Holder {
//         private static final ChronicleLogManager INSTANCE = new ChronicleLogManager();
// 
//         private Holder() {
// 
//         }
//     }
// }
// 
// Path: logger-core/src/main/java/net/openhft/chronicle/logger/ChronicleLogWriter.java
// public interface ChronicleLogWriter extends Closeable {
// 
//     void write(
//             ChronicleLogLevel level,
//             long timestamp,
//             String threadName,
//             String loggerName,
//             String message);
// 
//     void write(
//             ChronicleLogLevel level,
//             long timestamp,
//             String threadName,
//             String loggerName,
//             String message,
//             Throwable throwable,
//             Object... args);
// 
// }


import net.openhft.chronicle.logger.ChronicleLogManager;
import net.openhft.chronicle.logger.ChronicleLogWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.LogManager;
import java.util.logging.Logger;

    @Override
    public Logger getLogger(final String name) {
        try {
            return doGetLogger(name);
        } catch (Exception e) {
            System.err.println("Unable to initialize chronicle-logger-jul (" + name + ")\n  " + e.getMessage());
        }

        return ChronicleLogger.Null.INSTANCE;
    }

    @Override
    public Enumeration<String> getLoggerNames() {
        return Collections.enumeration(this.loggers.keySet());
    }

    @Override
    public void reset() throws SecurityException {
        this.loggers.clear();
        this.manager.clear();
    }

    // *************************************************************************
    //
    // *************************************************************************

    private synchronized Logger doGetLogger(String name) throws IOException {
        Logger logger = loggers.get(name);
        if (logger == null) {
// Path: logger-core/src/main/java/net/openhft/chronicle/logger/ChronicleLogManager.java
// public class ChronicleLogManager {
//     private ChronicleLogConfig cfg;
//     private Map<String, ChronicleLogWriter> writers;
// 
//     private ChronicleLogManager() {
//         this.cfg = ChronicleLogConfig.load();
//         this.writers = new ConcurrentHashMap<>();
//     }
// 
//     public static ChronicleLogManager getInstance() {
//         return Holder.INSTANCE;
//     }
// 
//     public ChronicleLogConfig cfg() {
//         return this.cfg;
//     }
// 
//     public void clear() {
//         for (final ChronicleLogWriter writer : writers.values()) {
//             try {
//                 writer.close();
//             } catch (IOException e) {
//             }
//         }
// 
//         writers.clear();
//     }
// 
//     public void reload() {
//         clear();
// 
//         this.cfg = ChronicleLogConfig.load();
//         this.writers = new ConcurrentHashMap<>();
//     }
// 
//     public ChronicleLogWriter getWriter(String name) {
//         if (this.cfg == null) {
//             throw new IllegalArgumentException("ChronicleLogManager is not configured");
//         }
// 
//         final String path = cfg.getString(name, ChronicleLogConfig.KEY_PATH);
//         if (path != null) {
//             // Creating a Queue takes some time. Other threads might be blocked for longer periods.
//             return writers.computeIfAbsent(path, p-> new DefaultChronicleLogWriter(newChronicle(p, name)));
//         } else {
//             throw new IllegalArgumentException(
//                     "chronicle.logger.root.path is not defined, chronicle.logger." + name + ".path is not defined"
//             );
//         }
//     }
// 
//     // *************************************************************************
//     //
//     // *************************************************************************
// 
//     private ChronicleQueue newChronicle(String path, String name) {
//         final String wireType = cfg.getString(name, ChronicleLogConfig.KEY_WIRETYPE);
//         ChronicleQueue cq = this.cfg.getAppenderConfig().build(path, wireType);
//         if (!cfg.getBoolean(name, ChronicleLogConfig.KEY_APPEND, true)) {
//             // TODO re-enable when it's implemented. ATM it throws UnsupportedOperationException...
//             //cq.clear();
//         }
//         return cq;
//     }
// 
//     // *************************************************************************
//     //
//     // *************************************************************************
// 
//     private static class Holder {
//         private static final ChronicleLogManager INSTANCE = new ChronicleLogManager();
// 
//         private Holder() {
// 
//         }
//     }
// }
// 
// Path: logger-core/src/main/java/net/openhft/chronicle/logger/ChronicleLogWriter.java
// public interface ChronicleLogWriter extends Closeable {
// 
//     void write(
//             ChronicleLogLevel level,
//             long timestamp,
//             String threadName,
//             String loggerName,
//             String message);
// 
//     void write(
//             ChronicleLogLevel level,
//             long timestamp,
//             String threadName,
//             String loggerName,
//             String message,
//             Throwable throwable,
//             Object... args);
// 
// }


// Path: logger-jul/src/main/java/net/openhft/chronicle/logger/jul/ChronicleLoggerManager.java
import net.openhft.chronicle.logger.ChronicleLogManager;
import net.openhft.chronicle.logger.ChronicleLogWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.LogManager;
import java.util.logging.Logger;


    @Override
    public Logger getLogger(final String name) {
        try {
            return doGetLogger(name);
        } catch (Exception e) {
            System.err.println("Unable to initialize chronicle-logger-jul (" + name + ")\n  " + e.getMessage());
        }

        return ChronicleLogger.Null.INSTANCE;
    }

    @Override
    public Enumeration<String> getLoggerNames() {
        return Collections.enumeration(this.loggers.keySet());
    }

    @Override
    public void reset() throws SecurityException {
        this.loggers.clear();
        this.manager.clear();
    }

    // *************************************************************************
    //
    // *************************************************************************

    private synchronized Logger doGetLogger(String name) throws IOException {
        Logger logger = loggers.get(name);
        if (logger == null) {
            final ChronicleLogWriter writer = manager.getWriter(name);