ReplicationQueue: Revert back from Flogger to slf4j logging

Slf4j's Mapped Diagnostic Context (MDC) is used to add the replication Id
into the logs and this was not adapted in the migration to Flogger,
resulting in the replication Id being omitted from the logs.

Flogger does not support MDC in the same way as slf4j, but provides a log
context which could be used. This would however change the format of the log
output. An alternative would be to manually update all the log statements
to include the replication Id. The downside of this approach is that we
need to remember to manually add it in any new logs that get added.

Instead of attempting either of those, just revert back to using slf4j.

This reverts commit 425f4f20218986615593da1a9319466743ee12eb.

Note that this is not a pure revert of 425f4f2; following that commit
several new logs were added. This reverts the commit and adapts the new
logs to also use slf4j.

Bug: Issue 12678
Change-Id: I3002afdac7c31786de5b611b32fa3f4c1a80e657
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
index 5a45be9..48694bf 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -52,7 +52,6 @@
 import com.google.gerrit.server.project.ProjectCache;
 import com.google.gerrit.server.project.ProjectState;
 import com.google.gerrit.server.util.RequestContext;
-import com.google.gerrit.util.logging.NamedFluentLogger;
 import com.google.inject.Inject;
 import com.google.inject.Injector;
 import com.google.inject.Provider;
@@ -82,9 +81,10 @@
 import org.eclipse.jgit.transport.RemoteConfig;
 import org.eclipse.jgit.transport.RemoteRefUpdate;
 import org.eclipse.jgit.transport.URIish;
+import org.slf4j.Logger;
 
 public class Destination {
-  private static final NamedFluentLogger repLog = ReplicationQueue.repLog;
+  private static final Logger repLog = ReplicationQueue.repLog;
 
   private static final String PROJECT_NOT_AVAILABLE = "source project %s not available";
 
@@ -154,7 +154,7 @@
           builder.add(g.getUUID());
           addRecursiveParents(g.getUUID(), builder, groupIncludeCache);
         } else {
-          repLog.atWarning().log("Group \"%s\" not recognized, removing from authGroup", name);
+          repLog.warn("Group \"{}\" not recognized, removing from authGroup", name);
         }
       }
       remoteUser = new RemoteSiteUser(new ListGroupMembership(builder.build()));
@@ -231,7 +231,7 @@
   public int shutdown() {
     int cnt = 0;
     if (pool != null) {
-      repLog.atWarning().log("Cancelling replication events");
+      repLog.warn("Cancelling replication events");
 
       foreachPushOp(
           pending,
@@ -265,8 +265,7 @@
     if (!config.replicateHiddenProjects()
         && state.getProject().getState()
             == com.google.gerrit.extensions.client.ProjectState.HIDDEN) {
-      repLog.atFine().log(
-          "Project %s is hidden and replication of hidden projects is disabled", name);
+      repLog.debug("Project {} is hidden and replication of hidden projects is disabled", name);
       return false;
     }
 
@@ -279,9 +278,10 @@
       permissionBackend.user(user).project(state.getNameKey()).check(permissionToCheck);
       return true;
     } catch (AuthException e) {
-      repLog.atFine().log(
-          "Project %s is not visible to current user %s",
-          name, user.getUserName().orElse("unknown"));
+      repLog.debug(
+          "Project {} is not visible to current user {}",
+          name,
+          user.getUserName().orElse("unknown"));
       return false;
     }
   }
@@ -298,20 +298,19 @@
                   try {
                     projectState = projectCache.checkedGet(project);
                   } catch (IOException e) {
-                    repLog.atWarning().withCause(e).log(
-                        "Error reading project %s from cache", project);
+                    repLog.warn("Error reading project {} from cache", project, e);
                     return false;
                   }
                   if (projectState == null) {
-                    repLog.atFine().log("Project %s does not exist", project);
+                    repLog.debug("Project {} does not exist", project);
                     throw new NoSuchProjectException(project);
                   }
                   if (!projectState.statePermitsRead()) {
-                    repLog.atFine().log("Project %s does not permit read", project);
+                    repLog.debug("Project {} does not permit read", project);
                     return false;
                   }
                   if (!shouldReplicate(projectState, userProvider.get())) {
-                    repLog.atFine().log("Project %s should not be replicated", project);
+                    repLog.debug("Project {} should not be replicated", project);
                     return false;
                   }
                   if (PushOne.ALL_REFS.equals(ref)) {
@@ -324,9 +323,11 @@
                         .ref(ref)
                         .check(RefPermission.READ);
                   } catch (AuthException e) {
-                    repLog.atFine().log(
-                        "Ref %s on project %s is not visible to calling user",
-                        ref, project, userProvider.get().getUserName().orElse("unknown"));
+                    repLog.debug(
+                        "Ref {} on project {} is not visible to calling user {}",
+                        ref,
+                        project,
+                        userProvider.get().getUserName().orElse("unknown"));
                     return false;
                   }
                   return true;
@@ -378,10 +379,10 @@
   void schedule(
       Project.NameKey project, String ref, URIish uri, ReplicationState state, boolean now) {
     if (!shouldReplicate(project, ref, state)) {
-      repLog.atFine().log("Not scheduling replication %s:%s => %s", project, ref, uri);
+      repLog.debug("Not scheduling replication {}:{} => {}", project, ref, uri);
       return;
     }
-    repLog.atInfo().log("scheduling replication %s:%s => %s", project, ref, uri);
+    repLog.info("scheduling replication {}:{} => {}", project, ref, uri);
 
     if (!config.replicatePermissions()) {
       PushOne e;
@@ -423,8 +424,7 @@
         task.addState(ref, state);
       }
       state.increasePushTaskCount(project.get(), ref);
-      repLog.atInfo().log(
-          "scheduled %s:%s => %s to run after %ds", project, ref, task, config.getDelay());
+      repLog.info("scheduled {}:{} => {} to run after {}s", project, ref, task, config.getDelay());
     }
   }
 
@@ -590,7 +590,7 @@
 
   boolean wouldPushProject(Project.NameKey project) {
     if (!shouldReplicate(project)) {
-      repLog.atFine().log("Skipping replication of project %s", project.get());
+      repLog.debug("Skipping replication of project {}", project.get());
       return false;
     }
 
@@ -602,8 +602,7 @@
 
     boolean matches = (new ReplicationFilter(projects)).matches(project);
     if (!matches) {
-      repLog.atFine().log(
-          "Skipping replication of project %s; does not match filter", project.get());
+      repLog.debug("Skipping replication of project {}; does not match filter", project.get());
     }
     return matches;
   }
@@ -628,7 +627,7 @@
 
   boolean wouldPushRef(String ref) {
     if (!config.replicatePermissions() && RefNames.REFS_CONFIG.equals(ref)) {
-      repLog.atFine().log("Skipping push of ref %s; it is a meta ref", ref);
+      repLog.debug("Skipping push of ref {}; it is a meta ref", ref);
       return false;
     }
     for (RefSpec s : config.getRemoteConfig().getPushRefSpecs()) {
@@ -636,7 +635,7 @@
         return true;
       }
     }
-    repLog.atFine().log("Skipping push of ref %s; it does not match push ref specs", ref);
+    repLog.debug("Skipping push of ref {}; it does not match push ref specs", ref);
     return false;
   }
 
@@ -668,8 +667,7 @@
         } else if (remoteNameStyle.equals("basenameOnly")) {
           name = FilenameUtils.getBaseName(name);
         } else if (!remoteNameStyle.equals("slash")) {
-          repLog.atFine().log(
-              "Unknown remoteNameStyle: %s, falling back to slash", remoteNameStyle);
+          repLog.debug("Unknown remoteNameStyle: {}, falling back to slash", remoteNameStyle);
         }
         String replacedPath =
             ReplicationQueue.replaceName(uri.getPath(), name, isSingleProjectMatch());
@@ -758,7 +756,7 @@
       try {
         eventDispatcher.get().postEvent(new Branch.NameKey(project, ref), event);
       } catch (PermissionBackendException e) {
-        repLog.atSevere().withCause(e).log("error posting event");
+        repLog.error("error posting event", e);
       }
     }
   }
@@ -772,7 +770,7 @@
       try {
         eventDispatcher.get().postEvent(new Branch.NameKey(project, ref), event);
       } catch (PermissionBackendException e) {
-        repLog.atSevere().withCause(e).log("error posting event");
+        repLog.error("error posting event", e);
       }
     }
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/LocalFS.java b/src/main/java/com/googlesource/gerrit/plugins/replication/LocalFS.java
index 8efe4bc..aa6e16c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/LocalFS.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/LocalFS.java
@@ -43,9 +43,9 @@
         u.disableRefLog();
         u.link(head);
       }
-      repLog.atInfo().log("Created local repository: %s", uri);
+      repLog.info("Created local repository: {}", uri);
     } catch (IOException e) {
-      repLog.atSevere().withCause(e).log("Error creating local repository %s", uri.getPath());
+      repLog.error("Error creating local repository {}", uri.getPath(), e);
       return false;
     }
     return true;
@@ -55,9 +55,9 @@
   public boolean deleteProject(Project.NameKey project) {
     try {
       recursivelyDelete(new File(uri.getPath()));
-      repLog.atInfo().log("Deleted local repository: %s", uri);
+      repLog.info("Deleted local repository: {}", uri);
     } catch (IOException e) {
-      repLog.atSevere().withCause(e).log("Error deleting local repository %s:\n", uri.getPath());
+      repLog.error("Error deleting local repository {}:\n", uri.getPath(), e);
       return false;
     }
     return true;
@@ -71,8 +71,7 @@
         u.link(newHead);
       }
     } catch (IOException e) {
-      repLog.atSevere().withCause(e).log(
-          "Failed to update HEAD of repository %s to %s", uri.getPath(), newHead);
+      repLog.error("Failed to update HEAD of repository {} to {}", uri.getPath(), newHead, e);
       return false;
     }
     return true;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
index 2782b83..966d7c0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -161,16 +161,17 @@
 
   @Override
   public void cancel() {
-    repLog.atInfo().log("Replication [%s] to %s was canceled", HexFormat.fromInt(id), getURI());
+    repLog.info("Replication [{}] to {} was canceled", HexFormat.fromInt(id), getURI());
     canceledByReplication();
     pool.pushWasCanceled(this);
   }
 
   @Override
   public void setCanceledWhileRunning() {
-    repLog.atInfo().log(
-        "Replication [%s] to %s was canceled while being executed",
-        HexFormat.fromInt(id), getURI());
+    repLog.info(
+        "Replication [{}] to {} was canceled while being executed",
+        HexFormat.fromInt(id),
+        getURI());
     canceledWhileRunning.set(true);
   }
 
@@ -225,10 +226,10 @@
     if (ALL_REFS.equals(ref)) {
       delta.clear();
       pushAllRefs = true;
-      repLog.atFinest().log("Added all refs for replication to %s", uri);
+      repLog.trace("Added all refs for replication to {}", uri);
     } else if (!pushAllRefs) {
       delta.add(ref);
-      repLog.atFinest().log("Added ref %s for replication to %s", ref, uri);
+      repLog.trace("Added ref {} for replication to {}", ref, uri);
     }
   }
 
@@ -316,18 +317,18 @@
     RunwayStatus status = pool.requestRunway(this);
     if (!status.isAllowed()) {
       if (status.isCanceled()) {
-        repLog.atInfo().log(
-            "PushOp for replication to %s was canceled and thus won't be rescheduled", uri);
+        repLog.info("PushOp for replication to {} was canceled and thus won't be rescheduled", uri);
       } else {
-        repLog.atInfo().log(
-            "Rescheduling replication to %s to avoid collision with the in-flight push [%s].",
-            uri, HexFormat.fromInt(status.getInFlightPushId()));
+        repLog.info(
+            "Rescheduling replication to {} to avoid collision with the in-flight push [{}].",
+            uri,
+            HexFormat.fromInt(status.getInFlightPushId()));
         pool.reschedule(this, Destination.RetryReason.COLLISION);
       }
       return;
     }
 
-    repLog.atInfo().log("Replication to %s started...", uri);
+    repLog.info("Replication to {} started...", uri);
     Timer1.Context context = metrics.start(config.getName());
     try {
       long startedAt = context.getStartTime();
@@ -336,9 +337,12 @@
       git = gitManager.openRepository(projectName);
       runImpl();
       long elapsed = NANOSECONDS.toMillis(context.stop());
-      repLog.atInfo().log(
-          "Replication to %s completed in %dms, %dms delay, %d retries",
-          uri, elapsed, delay, retryCount);
+      repLog.info(
+          "Replication to {} completed in {}ms, {}ms delay, {} retries",
+          uri,
+          elapsed,
+          delay,
+          retryCount);
     } catch (RepositoryNotFoundException e) {
       stateLog.error(
           "Cannot replicate " + projectName + "; Local repository error: " + e.getMessage(),
@@ -355,7 +359,7 @@
           || msg.contains("unavailable")) {
         createRepository();
       } else {
-        repLog.atSevere().log("Cannot replicate %s; Remote repository error: %s", projectName, msg);
+        repLog.error("Cannot replicate {}; Remote repository error: {}", projectName, msg);
       }
 
     } catch (NoRemoteRepositoryException e) {
@@ -365,10 +369,10 @@
     } catch (TransportException e) {
       Throwable cause = e.getCause();
       if (cause instanceof JSchException && cause.getMessage().startsWith("UnknownHostKey:")) {
-        repLog.atSevere().log("Cannot replicate to %s: %s", uri, cause.getMessage());
+        repLog.error("Cannot replicate to {}: {}", uri, cause.getMessage());
       } else if (e instanceof LockFailureException) {
         lockRetryCount++;
-        repLog.atSevere().log("Cannot replicate to %s due to lock failure", uri);
+        repLog.error("Cannot replicate to {} due to lock failure", uri);
 
         // The remote push operation should be retried.
         if (lockRetryCount <= maxLockRetries) {
@@ -378,14 +382,14 @@
             pool.reschedule(this, Destination.RetryReason.TRANSPORT_ERROR);
           }
         } else {
-          repLog.atSevere().log(
-              "Giving up after %d lock failures during replication to %s", lockRetryCount, uri);
+          repLog.error(
+              "Giving up after {} lock failures during replication to {}", lockRetryCount, uri);
         }
       } else {
         if (canceledWhileRunning.get()) {
           logCanceledWhileRunningException(e);
         } else {
-          repLog.atSevere().withCause(e).log("Cannot replicate to %s", uri);
+          repLog.error("Cannot replicate to {}", uri, e);
           // The remote push operation should be retried.
           pool.reschedule(this, Destination.RetryReason.TRANSPORT_ERROR);
         }
@@ -403,7 +407,7 @@
   }
 
   private void logCanceledWhileRunningException(TransportException e) {
-    repLog.atInfo().withCause(e).log("Cannot replicate to %s. It was canceled while running", uri);
+    repLog.info("Cannot replicate to {}. It was canceled while running", uri, e);
   }
 
   private void createRepository() {
@@ -412,11 +416,10 @@
         Ref head = git.exactRef(Constants.HEAD);
         if (replicationQueue.createProject(
             config.getName(), projectName, head != null ? getName(head) : null)) {
-          repLog.atWarning().log("Missing repository created; retry replication to %s", uri);
+          repLog.warn("Missing repository created; retry replication to {}", uri);
           pool.reschedule(this, Destination.RetryReason.REPOSITORY_MISSING);
         } else {
-          repLog.atWarning().log(
-              "Missing repository could not be created when replicating %s", uri);
+          repLog.warn("Missing repository could not be created when replicating {}", uri);
         }
       } catch (IOException ioe) {
         stateLog.error(
@@ -458,7 +461,7 @@
       return new PushResult();
     }
 
-    repLog.atInfo().log("Push to %s references: %s", uri, todo);
+    repLog.info("Push to {} references: {}", uri, todo);
 
     return tn.push(NullProgressMonitor.INSTANCE, todo);
   }
@@ -511,7 +514,7 @@
     Map<String, Ref> remote = listRemote(tn);
     for (Ref src : local.values()) {
       if (!canPushRef(src.getName(), noPerms)) {
-        repLog.atFine().log("Skipping push of ref %s", src.getName());
+        repLog.debug("Skipping push of ref {}", src.getName());
         continue;
       }
 
@@ -528,7 +531,7 @@
     if (config.isMirror()) {
       for (Ref ref : remote.values()) {
         if (Constants.HEAD.equals(ref.getName())) {
-          repLog.atFine().log("Skipping deletion of %s", ref.getName());
+          repLog.debug("Skipping deletion of {}", ref.getName());
           continue;
         }
         RefSpec spec = matchDst(ref.getName());
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/RemoteSsh.java b/src/main/java/com/googlesource/gerrit/plugins/replication/RemoteSsh.java
index e313079..2d66431 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/RemoteSsh.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/RemoteSsh.java
@@ -42,14 +42,18 @@
     OutputStream errStream = sshHelper.newErrorBufferStream();
     try {
       sshHelper.executeRemoteSsh(uri, cmd, errStream);
-      repLog.atInfo().log("Created remote repository: %s", uri);
+      repLog.info("Created remote repository: {}", uri);
     } catch (IOException e) {
-      repLog.atSevere().withCause(e).log(
-          "Error creating remote repository at %s:\n"
-              + "  Exception: %s\n"
-              + "  Command: %s\n"
-              + "  Output: %s",
-          uri, e, cmd, errStream);
+      repLog.error(
+          "Error creating remote repository at {}:\n"
+              + "  Exception: {}\n"
+              + "  Command: {}\n"
+              + "  Output: {}",
+          uri,
+          e,
+          cmd,
+          errStream,
+          e);
       return false;
     }
     return true;
@@ -62,14 +66,18 @@
     OutputStream errStream = sshHelper.newErrorBufferStream();
     try {
       sshHelper.executeRemoteSsh(uri, cmd, errStream);
-      repLog.atInfo().log("Deleted remote repository: %s", uri);
+      repLog.info("Deleted remote repository: {}", uri);
     } catch (IOException e) {
-      repLog.atSevere().withCause(e).log(
-          "Error deleting remote repository at %s}:\n"
-              + "  Exception: %s\n"
-              + "  Command: %s\n"
-              + "  Output: %s",
-          uri, e, cmd, errStream);
+      repLog.error(
+          "Error deleting remote repository at {}}:\n"
+              + "  Exception: {}\n"
+              + "  Command: {}\n"
+              + "  Output: {}",
+          uri,
+          e,
+          cmd,
+          errStream,
+          e);
       return false;
     }
     return true;
@@ -84,12 +92,17 @@
     try {
       sshHelper.executeRemoteSsh(uri, cmd, errStream);
     } catch (IOException e) {
-      repLog.atSevere().withCause(e).log(
-          "Error updating HEAD of remote repository at %s to %s:\n"
-              + "  Exception: %s\n"
-              + "  Command: %s\n"
-              + "  Output: %s",
-          uri, newHead, e, cmd, errStream);
+      repLog.error(
+          "Error updating HEAD of remote repository at {} to {}:\n"
+              + "  Exception: {}\n"
+              + "  Command: {}\n"
+              + "  Output: {}",
+          uri,
+          newHead,
+          e,
+          cmd,
+          errStream,
+          e);
       return false;
     }
     return true;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
index 2783584..e494c24 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
@@ -31,7 +31,6 @@
 import com.google.gerrit.server.UsedAt;
 import com.google.gerrit.server.events.EventDispatcher;
 import com.google.gerrit.server.git.WorkQueue;
-import com.google.gerrit.util.logging.NamedFluentLogger;
 import com.google.inject.Inject;
 import com.googlesource.gerrit.plugins.replication.PushResultProcessing.GitUpdateProcessing;
 import com.googlesource.gerrit.plugins.replication.ReplicationConfig.FilterType;
@@ -43,6 +42,8 @@
 import java.util.Queue;
 import java.util.Set;
 import org.eclipse.jgit.transport.URIish;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /** Manages automatic replication to remote repositories. */
 public class ReplicationQueue
@@ -51,7 +52,7 @@
         ProjectDeletedListener,
         HeadUpdatedListener {
   static final String REPLICATION_LOG_NAME = "replication_log";
-  static final NamedFluentLogger repLog = NamedFluentLogger.forName(REPLICATION_LOG_NAME);
+  static final Logger repLog = LoggerFactory.getLogger(REPLICATION_LOG_NAME);
 
   private final ReplicationStateListener stateLog;
 
@@ -108,7 +109,7 @@
     running = false;
     int discarded = config.shutdown();
     if (discarded > 0) {
-      repLog.atWarning().log("Canceled %d replication events during shutdown", discarded);
+      repLog.warn("Canceled {} replication events during shutdown", discarded);
     }
   }
 
@@ -185,7 +186,7 @@
         cfg.schedule(project, refName, uri, state);
       }
     } else {
-      repLog.atFine().log("Skipping ref %s on project %s", refName, project.get());
+      repLog.debug("Skipping ref {} on project {}", refName, project.get());
     }
 
     if (withoutState) {
@@ -199,12 +200,12 @@
       replaying = true;
       for (ReplicationTasksStorage.ReplicateRefUpdate t : replicationTasksStorage.list()) {
         if (t == null) {
-          repLog.atWarning().log("Encountered null replication event in ReplicationTasksStorage");
+          repLog.warn("Encountered null replication event in ReplicationTasksStorage");
           continue;
         }
         String eventKey = String.format("%s:%s", t.project, t.ref);
         if (!eventsReplayed.contains(eventKey)) {
-          repLog.atInfo().log("Firing pending task %s", eventKey);
+          repLog.info("Firing pending task {}", eventKey);
           onGitReferenceUpdated(t.project, t.ref);
           eventsReplayed.add(eventKey);
         }
@@ -235,7 +236,7 @@
     for (ReferenceUpdatedEvent event : beforeStartupEventsQueue) {
       String eventKey = String.format("%s:%s", event.getProjectName(), event.getRefName());
       if (!eventsReplayed.contains(eventKey)) {
-        repLog.atInfo().log("Firing pending task %s", event);
+        repLog.info("Firing pending task {}", event);
         onGitReferenceUpdated(event.getProjectName(), event.getRefName());
         eventsReplayed.add(eventKey);
       }
@@ -248,7 +249,7 @@
       return Collections.emptySet();
     }
     if (!running) {
-      repLog.atSevere().log("Replication plugin did not finish startup before event");
+      repLog.error("Replication plugin did not finish startup before event");
       return Collections.emptySet();
     }
 
@@ -273,7 +274,7 @@
         try {
           uri = new URIish(url);
         } catch (URISyntaxException e) {
-          repLog.atWarning().log("adminURL '%s' is invalid: %s", url, e.getMessage());
+          repLog.warn("adminURL '{}' is invalid: {}", url, e.getMessage());
           continue;
         }
 
@@ -281,13 +282,13 @@
           String path =
               replaceName(uri.getPath(), projectName.get(), config.isSingleProjectMatch());
           if (path == null) {
-            repLog.atWarning().log("adminURL %s does not contain ${name}", uri);
+            repLog.warn("adminURL {} does not contain ${name}", uri);
             continue;
           }
 
           uri = uri.setPath(path);
           if (!isSSH(uri)) {
-            repLog.atWarning().log("adminURL '%s' is invalid: only SSH is supported", uri);
+            repLog.warn("adminURL '{}' is invalid: only SSH is supported", uri);
             continue;
           }
         }
@@ -343,7 +344,7 @@
   }
 
   private void warnCannotPerform(String op, URIish uri) {
-    repLog.atWarning().log("Cannot %s on remote site %s.", op, uri);
+    repLog.warn("Cannot {} on remote site {}.", op, uri);
   }
 
   private static class ReferenceUpdatedEvent {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationStateLogger.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationStateLogger.java
index 3e73033..f2d55de 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationStateLogger.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationStateLogger.java
@@ -31,19 +31,19 @@
   @Override
   public void warn(String msg, ReplicationState... states) {
     stateWriteErr("Warning: " + msg, states);
-    repLog.atWarning().log(msg);
+    repLog.warn(msg);
   }
 
   @Override
   public void error(String msg, ReplicationState... states) {
     stateWriteErr("Error: " + msg, states);
-    repLog.atSevere().log(msg);
+    repLog.error(msg);
   }
 
   @Override
   public void error(String msg, Throwable t, ReplicationState... states) {
     stateWriteErr("Error: " + msg, states);
-    repLog.atSevere().withCause(t).log(msg);
+    repLog.error(msg, t);
   }
 
   private void stateWriteErr(String msg, ReplicationState[] states) {