Skip to content

Commit

Permalink
Log4j update (qzind#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brett Berenz authored Dec 17, 2021
1 parent db01438 commit 8368d99
Show file tree
Hide file tree
Showing 113 changed files with 395 additions and 385 deletions.
11 changes: 8 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@
<jar compress="${jar.compress}" index="${jar.index}" destfile="${dist.dir}/${project.filename}.jar" duplicate="preserve">
<fileset dir="${build.dir}/${project.filename}"/>
<!-- Some root level files will cause jlink to fail, they need to be cleaned up -->
<fileset dir="${out.dir}/libs-temp" excludes="*.class,LICENSE,jetty-dir.css"/>
<fileset dir="${out.dir}/libs-temp" excludes="*.class,LICENSE,jetty-dir.css,about.html,Log4j-*"/>
<manifest>
<attribute name="Application-Name" value="${project.name}"/>
<attribute name="Main-Class" value="qz.App"/>
<attribute name="Permissions" value="all-permissions"/>
<attribute name="Multi-Release" value="true"/>
</manifest>
</jar>
<delete dir="${out.dir}/libs-temp" includeemptydirs="true" defaultexcludes="false"/>
Expand Down Expand Up @@ -156,10 +157,14 @@
<!-- Remove files that can/did collide during unpacking -->
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${out.dir}/libs-temp">
<include name="**/META-INF/**"/>
<exclude name="**/META-INF/maven/**"/>
<include name="LICENSE*"/>
<include name="README*"/>
<include name="**/META-INF/**"/>
<!-- Used by SecurityInfo.getMavenVersions() -->
<exclude name="**/META-INF/maven/**"/>
<!-- Required by log4j -->
<exclude name="**/META-INF/**/apache/logging/**"/>
<exclude name="**/META-INF/services/**"/>
</fileset>
</delete>
</target>
Expand Down
Binary file removed lib/logging/apache-log4j-extras-1.2.17.jar
Binary file not shown.
Binary file removed lib/logging/log4j-1.2.17.jar
Binary file not shown.
Binary file added lib/logging/log4j-api-2.16.0.jar
Binary file not shown.
Binary file added lib/logging/log4j-core-2.16.0.jar
Binary file not shown.
Binary file removed lib/logging/slf4j-api-1.7.12.jar
Binary file not shown.
Binary file removed lib/logging/slf4j-log4j12-1.7.12.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions src/com/apple/OSXAdapterWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
package com.apple;

import com.github.zafarkhaja.semver.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import qz.common.Constants;
import qz.utils.MacUtilities;

Expand All @@ -27,7 +27,7 @@
* @author Tres Finocchiaro
*/
public class OSXAdapterWrapper implements InvocationHandler {
private static final Logger log = LoggerFactory.getLogger(OSXAdapterWrapper.class);
private static final Logger log = LogManager.getLogger(OSXAdapterWrapper.class);
public static final boolean legacyMode = Constants.JAVA_VERSION.lessThan(Version.valueOf("9.0.0"));

private Object target;
Expand Down
29 changes: 0 additions & 29 deletions src/log4j.xml

This file was deleted.

16 changes: 16 additions & 0 deletions src/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="[%p] %d{ISO8601} @ %c:%L%n\t%m%n"/>
</Console>
</Appenders>
<Loggers>
<!-- Packages -->
<Logger name="qz" level="trace"/>
<!-- Default -->
<Root level="warn">
<AppenderRef ref="console"/>
</Root>
</Loggers>
</Configuration>
51 changes: 27 additions & 24 deletions src/qz/App.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package qz;

import org.apache.log4j.Level;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.rolling.FixedWindowRollingPolicy;
import org.apache.log4j.rolling.RollingFileAppender;
import org.apache.log4j.rolling.SizeBasedTriggeringPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.appender.RollingFileAppender;
import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
import org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
import org.apache.logging.log4j.core.filter.ThresholdFilter;
import org.apache.logging.log4j.core.layout.PatternLayout;
import qz.common.Constants;
import qz.installer.Installer;
import qz.installer.certificate.CertificateManager;
Expand All @@ -22,7 +25,7 @@
import java.util.Properties;

public class App {
private static final Logger log = LoggerFactory.getLogger(App.class);
private static final Logger log = LogManager.getLogger(App.class);
private static Properties trayProperties = null;

public static void main(String ... args) {
Expand Down Expand Up @@ -80,23 +83,23 @@ public static Properties getTrayProperties() {
}

private static void setupFileLogging() {
FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
rollingPolicy.setFileNamePattern(FileUtilities.USER_DIR + File.separator + Constants.LOG_FILE + ".log.%i");
rollingPolicy.setMaxIndex(Constants.LOG_ROTATIONS);

SizeBasedTriggeringPolicy triggeringPolicy = new SizeBasedTriggeringPolicy(Constants.LOG_SIZE);

RollingFileAppender fileAppender = new RollingFileAppender();
fileAppender.setLayout(new PatternLayout("%d{ISO8601} [%p] %m%n"));
fileAppender.setThreshold(Level.DEBUG);
fileAppender.setFile(FileUtilities.USER_DIR + File.separator + Constants.LOG_FILE + ".log");
fileAppender.setRollingPolicy(rollingPolicy);
fileAppender.setTriggeringPolicy(triggeringPolicy);
fileAppender.setEncoding("UTF-8");
RollingFileAppender fileAppender = RollingFileAppender.newBuilder()
.setName("log-file")
.withAppend(true)
.setLayout(PatternLayout.newBuilder().withPattern("%d{ISO8601} [%p] %m%n").build())
.setFilter(ThresholdFilter.createFilter(Level.DEBUG, Filter.Result.ACCEPT, Filter.Result.DENY))
.withFileName(FileUtilities.USER_DIR + File.separator + Constants.LOG_FILE + ".log")
.withFilePattern(FileUtilities.USER_DIR + File.separator + Constants.LOG_FILE + ".log.%i")
.withStrategy(DefaultRolloverStrategy.newBuilder().withMax(String.valueOf(Constants.LOG_ROTATIONS)).build())
.withPolicy(SizeBasedTriggeringPolicy.createPolicy(String.valueOf(Constants.LOG_SIZE)))
.withImmediateFlush(true)
.build();
fileAppender.start();

fileAppender.setImmediateFlush(true);
fileAppender.activateOptions();
LoggerUtilities.getRootLogger().addAppender(fileAppender);

org.apache.log4j.Logger.getRootLogger().addAppender(fileAppender);
//disable jetty logging
System.setProperty("org.eclipse.jetty.util.log.class", "org.eclipse.jetty.util.log.StdErrLog");
System.setProperty("org.eclipse.jetty.LEVEL", "OFF");
}
}
6 changes: 3 additions & 3 deletions src/qz/auth/CRL.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package qz.auth;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import qz.utils.ConnectionUtilities;

Expand All @@ -16,7 +16,7 @@
*/
public class CRL {

private static final Logger log = LoggerFactory.getLogger(CRL.class);
private static final Logger log = LogManager.getLogger(CRL.class);

/** The URL to the QZ CRL. Should not be changed except for dev tests */
public static final String CRL_URL = "https://crl.qz.io";
Expand Down
6 changes: 3 additions & 3 deletions src/qz/auth/Certificate.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import org.bouncycastle.asn1.x500.style.BCStyle;
import org.bouncycastle.jce.PrincipalUtil;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import qz.App;
import qz.common.Constants;
import qz.utils.ByteUtilities;
Expand All @@ -35,7 +35,7 @@
*/
public class Certificate {

private static final Logger log = LoggerFactory.getLogger(Certificate.class);
private static final Logger log = LogManager.getLogger(Certificate.class);
private static final String QUIETLY_FAIL = "quiet";
public static final String OVERRIDE_CA_FLAG = "trustedRootCert";
public static final String OVERRIDE_CA_PROPERTY = "authcert.override";
Expand Down
6 changes: 3 additions & 3 deletions src/qz/build/Fetcher.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package qz.build;

import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import qz.utils.ShellUtilities;
import qz.utils.SystemUtilities;

Expand Down Expand Up @@ -44,7 +44,7 @@ public static Format parse(String url) {
}
}

private static final Logger log = LoggerFactory.getLogger(Fetcher.class);
private static final Logger log = LogManager.getLogger(Fetcher.class);

public static void main(String ... args) throws IOException {
new Fetcher("jlink/qz-tray-src_x.x.x", "https://github.com/qzind/tray/archive/master.tar.gz").fetch().uncompress();
Expand Down
9 changes: 5 additions & 4 deletions src/qz/build/JLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

import com.github.zafarkhaja.semver.Version;
import org.apache.commons.io.FileUtils;
import org.slf4j.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import qz.common.Constants;
import qz.utils.*;

Expand All @@ -24,7 +25,7 @@
import java.util.Locale;

public class JLink {
private static final Logger log = LoggerFactory.getLogger(JLink.class);
private static final Logger log = LogManager.getLogger(JLink.class);
private static final String JAVA_AMD64_VENDOR = "AdoptOpenJDK";
private static final String JAVA_ARM64_VENDOR = "BellSoft";
private static final String JAVA_VERSION = "11.0.12+7";
Expand Down Expand Up @@ -198,8 +199,8 @@ private JLink calculateDepList() throws IOException {

// JDK11.0.11+requires suppressing of missing deps
String raw = jdepsVersion.compareTo(Version.valueOf("11.0.10")) > 0 ?
ShellUtilities.executeRaw(jdepsPath.toString(), "--list-deps", "--ignore-missing-deps", jarPath.toString()) :
ShellUtilities.executeRaw(jdepsPath.toString(), "--list-deps", jarPath.toString());
ShellUtilities.executeRaw(jdepsPath.toString(), "--multi-release", "9", "--list-deps", "--ignore-missing-deps", jarPath.toString()) :
ShellUtilities.executeRaw(jdepsPath.toString(), "--multi-release", "9", "--list-deps", jarPath.toString());
if (raw == null || raw.trim().isEmpty() || raw.trim().startsWith("Warning") ) {
throw new IOException("An unexpected error occurred calling jdeps. Please check the logs for details.\n" + raw);
}
Expand Down
8 changes: 4 additions & 4 deletions src/qz/build/VendorArch.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package qz.build;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Locale;

Expand All @@ -20,7 +20,7 @@ public enum VendorArch {
ADOPT_AARCH64("aarch64", "aarch64", "arm64"),
BELL_AARCH64("aarch64", "aarch64", "arm64");

private static final Logger log = LoggerFactory.getLogger(VendorArch.class);
private static final Logger log = LogManager.getLogger(VendorArch.class);

String use;
String[] matches;
Expand All @@ -47,4 +47,4 @@ public static String match(String vendor, String arch, String fallback) {
return fallback;
}

}
}
8 changes: 4 additions & 4 deletions src/qz/build/VendorOs.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package qz.build;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Locale;

Expand All @@ -22,7 +22,7 @@ public enum VendorOs {
// Linux
// (skip, all vendors use "linux")

private static final Logger log = LoggerFactory.getLogger(VendorArch.class);
private static final Logger log = LogManager.getLogger(VendorArch.class);

String use;
String[] matches;
Expand All @@ -48,4 +48,4 @@ public static String match(String vendor, String os) {
return os;
}

}
}
6 changes: 3 additions & 3 deletions src/qz/build/VendorUrlPattern.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package qz.build;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Locale;

Expand All @@ -13,7 +13,7 @@ public enum VendorUrlPattern {
BELL("https://download.bell-sw.com/java/%s/bellsoft-jdk%s-%s-%s.%s");

private static final VendorUrlPattern DEFAULT_VENDOR = ADOPT;
private static final Logger log = LoggerFactory.getLogger(VendorUrlPattern.class);
private static final Logger log = LogManager.getLogger(VendorUrlPattern.class);

String pattern;
VendorUrlPattern(String pattern) {
Expand Down
6 changes: 3 additions & 3 deletions src/qz/common/AboutInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import qz.installer.certificate.KeyPairWrapper;
import qz.installer.certificate.CertificateManager;
import qz.utils.SystemUtilities;
Expand All @@ -30,7 +30,7 @@

public class AboutInfo {

private static final Logger log = LoggerFactory.getLogger(AboutInfo.class);
private static final Logger log = LogManager.getLogger(AboutInfo.class);

private static String preferredHostname = "localhost";

Expand Down
5 changes: 3 additions & 2 deletions src/qz/common/PropertyHelper.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package qz.common;

import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -11,7 +12,7 @@
* Created by Tres on 12/16/2015.
*/
public class PropertyHelper extends Properties {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(TrayManager.class);
private static final Logger log = LogManager.getLogger(TrayManager.class);
private String file;

/**
Expand Down
Loading

0 comments on commit 8368d99

Please sign in to comment.