package com.github.wolf480pl.log4j2_to_jul.context;

import java.util.logging.LogRecord;
import java.util.logging.Logger;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.MessageFactory;
import org.apache.logging.log4j.spi.AbstractLogger;

import com.github.wolf480pl.log4j2_to_jul.Util;

public class JULLogger extends AbstractLogger {
    private final Logger jul;

    public JULLogger(Logger jul) {
        super(jul.getName());
        this.jul = jul;
    }

    public JULLogger(String name) {
        super(name);
        this.jul = Logger.getLogger(name);
    }

    public JULLogger(String name, MessageFactory messageFactory) {
        super(name, messageFactory);
        this.jul = Logger.getLogger(name);
    }

    @Override
    protected boolean isEnabled(Level level, Marker marker, Message data, Throwable t) {
        return this.jul.isLoggable(Util.levelToJUL(level));
    }

    @Override
    protected boolean isEnabled(Level level, Marker marker, Object data, Throwable t) {
        return this.jul.isLoggable(Util.levelToJUL(level));
    }

    @Override
    protected boolean isEnabled(Level level, Marker marker, String data) {
        return this.jul.isLoggable(Util.levelToJUL(level));
    }

    @Override
    protected boolean isEnabled(Level level, Marker marker, String data, Object... p1) {
        return this.jul.isLoggable(Util.levelToJUL(level));
    }

    @Override
    protected boolean isEnabled(Level level, Marker marker, String data, Throwable t) {
        return this.jul.isLoggable(Util.levelToJUL(level));
    }

    @Override
    public void log(Marker marker, String fqcn, Level level, Message data, Throwable t) {
        LogRecord record = new LogRecord(Util.levelToJUL(level), data.getFormattedMessage());
        record.setThrown(t);
        record.setSourceClassName(fqcn);
        record.setLoggerName(this.jul.getName());
        // TODO: Propagate the marker
        this.jul.log(record);
    }

}

@@ -459,65 +459,298 @@
    p
-rivate final Logger jul;%0A%0A    public JULLogger(Logger jul
+ublic static final String DEFAULT_FORMAT = %22%252$s - %251$s%22;%0A    public static final String PASSTHRU_FORMAT = %22%25s%22;%0A    private final Logger jul;%0A    private final String format;%0A%0A    public JULLogger(Logger jul) %7B%0A        this(jul, null);%0A    %7D%0A%0A    public JULLogger(Logger jul, String format
 ) %7B%0A
@@ -799,24 +799,54 @@
 .jul = jul;%0A
+        this.format = format;%0A
     %7D%0A%0A    p
@@ -872,24 +872,117 @@
 ing name) %7B%0A
+        this(name, (String) null);%0A    %7D%0A%0A    public JULLogger(String name, String format) %7B%0A
         supe
@@ -1025,32 +1025,62 @@
 etLogger(name);%0A
+        this.format = format;%0A
     %7D%0A%0A    publi
@@ -1133,24 +1133,155 @@
 eFactory) %7B%0A
+        this(name, messageFactory, null);%0A    %7D%0A%0A    public JULLogger(String name, MessageFactory messageFactory, String format) %7B%0A
         supe
@@ -1344,24 +1344,54 @@
 gger(name);%0A
+        this.format = format;%0A
     %7D%0A%0A    @
@@ -2315,32 +2315,478 @@
  Throwable t) %7B%0A
+        final String msg;%0A        String mkName = (marker == null) ? %22%22 : marker.getName();%0A        if (this.format == null) %7B%0A            if (mkName.isEmpty()) %7B%0A                msg = data.getFormattedMessage();%0A            %7D else %7B%0A                msg = String.format(DEFAULT_FORMAT, mkName, data.getFormattedMessage());%0A            %7D%0A        %7D else %7B%0A            msg = String.format(this.format, mkName, data.getFormattedMessage());%0A        %7D%0A
         LogRecor
@@ -2838,34 +2838,11 @@
 l), 
-data.getFormattedMessage()
+msg
 );%0A 
@@ -2964,46 +2964,8 @@
 ));%0A
-        // TODO: Propagate the marker%0A
     

Add a format to JULLogger with which it can pass the Marker to the Logger from JUL.