Skip to content

Commit

Permalink
Log4j cleanup. Remove last traces of log4j v1 (and remove log4j1 brid…
Browse files Browse the repository at this point in the history
…ge to avoid them coming back). Create log4j2 settings for Handle Plugin.
  • Loading branch information
tdonohue committed Nov 15, 2024
1 parent c23f91a commit 76b54b3
Show file tree
Hide file tree
Showing 23 changed files with 91 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import com.google.common.io.Files;
import com.opencsv.CSVReader;
import com.opencsv.exceptions.CsvException;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.AbstractIntegrationTestWithDatabase;
import org.dspace.app.launcher.ScriptLauncher;
import org.dspace.app.scripts.handler.impl.TestDSpaceRunnableHandler;
Expand Down Expand Up @@ -51,7 +52,7 @@ public class MetadataExportSearchIT extends AbstractIntegrationTestWithDatabase
private Item[] itemsSubject2 = new Item[numberItemsSubject2];
private String filename;
private Collection collection;
private Logger logger = Logger.getLogger(MetadataExportSearchIT.class);
private Logger logger = LogManager.getLogger(MetadataExportSearchIT.class);
private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
private SearchService searchService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import java.sql.SQLException;
import java.util.Date;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.content.Item;
import org.dspace.core.Context;
import org.dspace.orcid.OrcidHistory;
Expand All @@ -24,7 +25,7 @@
*/
public class OrcidHistoryBuilder extends AbstractBuilder<OrcidHistory, OrcidHistoryService> {

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

private OrcidHistory orcidHistory;

Expand Down
5 changes: 0 additions & 5 deletions dspace-oai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<!-- TODO: This "bridge" should be removed as we should not support Log4j v1 syntax anymore -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
</dependency>

<!-- Testing -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import java.sql.SQLException;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.content.Bundle;
import org.dspace.content.Item;
import org.dspace.handle.factory.HandleServiceFactory;
Expand Down
4 changes: 0 additions & 4 deletions dspace-rdf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import java.util.List;

import jakarta.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.model.PageRest;
import org.dspace.app.rest.model.SearchEventRest;
import org.dspace.app.rest.model.SearchResultsRest;
Expand All @@ -31,7 +32,7 @@
@Component
public class SearchEventConverter {
/* Log4j logger */
private static final Logger log = Logger.getLogger(SearchEventConverter.class);
private static final Logger log = LogManager.getLogger(SearchEventConverter.class);

@Autowired
private ScopeResolver scopeResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import java.util.List;

import jakarta.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.signposting.model.LinksetNode;
import org.dspace.app.rest.signposting.model.LinksetRelationType;
import org.dspace.content.Bitstream;
Expand All @@ -25,7 +26,7 @@
*/
public class BitstreamLinksetProcessor extends BitstreamSignpostingProcessor {

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

private final BitstreamService bitstreamService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import java.util.List;

import jakarta.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.signposting.model.LinksetNode;
import org.dspace.app.rest.signposting.model.LinksetRelationType;
import org.dspace.content.Bitstream;
Expand All @@ -28,7 +29,7 @@
*/
public class BitstreamParentItemProcessor extends BitstreamSignpostingProcessor {

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

private final BitstreamService bitstreamService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.signposting.model.LinksetNode;
import org.dspace.app.rest.signposting.model.LinksetRelationType;
import org.dspace.content.Bitstream;
Expand All @@ -28,7 +29,7 @@
*/
public class BitstreamTypeProcessor extends BitstreamSignpostingProcessor {

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

@Autowired
private SimpleMapConverter mapConverterDSpaceToSchemaOrgUri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import java.util.List;

import jakarta.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.signposting.model.LinksetNode;
import org.dspace.app.rest.signposting.model.LinksetRelationType;
import org.dspace.content.Item;
Expand All @@ -37,7 +38,7 @@ public class ItemAuthorProcessor extends ItemSignpostingProcessor {
/**
* log4j category
*/
private static final Logger log = Logger.getLogger(ItemAuthorProcessor.class);
private static final Logger log = LogManager.getLogger(ItemAuthorProcessor.class);

private final ItemService itemService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import java.util.List;

import jakarta.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.signposting.model.LinksetNode;
import org.dspace.app.rest.signposting.model.LinksetRelationType;
import org.dspace.content.Bitstream;
Expand All @@ -33,7 +34,7 @@ public class ItemContentBitstreamsProcessor extends ItemSignpostingProcessor {
/**
* log4j category
*/
private static final Logger log = Logger.getLogger(ItemContentBitstreamsProcessor.class);
private static final Logger log = LogManager.getLogger(ItemContentBitstreamsProcessor.class);

public ItemContentBitstreamsProcessor(FrontendUrlService frontendUrlService) {
super(frontendUrlService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import java.util.List;

import jakarta.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.signposting.model.LinksetNode;
import org.dspace.app.rest.signposting.model.LinksetRelationType;
import org.dspace.content.Item;
Expand All @@ -23,7 +24,7 @@
*/
public class ItemDescribedbyProcessor extends ItemSignpostingProcessor {

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

private final ConfigurationService configurationService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.signposting.model.LinksetNode;
import org.dspace.app.rest.signposting.model.LinksetRelationType;
import org.dspace.content.Item;
Expand All @@ -25,7 +26,7 @@
*/
public class ItemLicenseProcessor extends ItemSignpostingProcessor {

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

private final CreativeCommonsService creativeCommonsService =
LicenseServiceFactory.getInstance().getCreativeCommonsService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import java.util.List;

import jakarta.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.signposting.model.LinksetNode;
import org.dspace.app.rest.signposting.model.LinksetRelationType;
import org.dspace.content.Item;
Expand All @@ -23,7 +24,7 @@
*/
public class ItemLinksetProcessor extends ItemSignpostingProcessor {

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

private final ConfigurationService configurationService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.signposting.model.LinksetNode;
import org.dspace.app.rest.signposting.model.LinksetRelationType;
import org.dspace.content.Item;
Expand All @@ -27,7 +28,7 @@
*/
public class ItemTypeProcessor extends ItemSignpostingProcessor {

private static final Logger log = Logger.getLogger(ItemTypeProcessor.class);
private static final Logger log = LogManager.getLogger(ItemTypeProcessor.class);
private static final String ABOUT_PAGE_URI = "https://schema.org/AboutPage";

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import java.util.List;

import jakarta.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.security.BitstreamMetadataReadPermissionEvaluatorPlugin;
import org.dspace.app.rest.signposting.model.LinksetNode;
import org.dspace.app.rest.signposting.processor.bitstream.BitstreamSignpostingProcessor;
Expand All @@ -37,7 +38,7 @@
@Service
public class LinksetServiceImpl implements LinksetService {

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

@Autowired
protected ItemService itemService;
Expand Down
4 changes: 0 additions & 4 deletions dspace-sword/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
</dependency>

<dependency>
<groupId>xom</groupId>
Expand Down
4 changes: 0 additions & 4 deletions dspace-swordv2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
</dependency>
</dependencies>

</project>
2 changes: 1 addition & 1 deletion dspace/bin/start-handle-server
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ rm -f $HANDLEDIR/txns/lock
# does not support more than one JVM writing to the same rolling log.
nohup java $JAVA_OPTS -classpath `$BINDIR/dspace classpath` \
-Ddspace.log.init.disable=true \
-Dlog4j.configuration=log4j-handle-plugin.properties \
-Dlog4j2.configurationFile=log4j2-handle-plugin.xml \
net.handle.server.Main $HANDLEDIR \
</dev/null >> $LOGDIR/handle-server.log 2>&1 &
2 changes: 1 addition & 1 deletion dspace/bin/start-handle-server.bat
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ echo.
echo NOTE: If you want to run the Handle Server as a backend process, re-execute this script
echo using the Windows "start" command. For example, "start /B start-handle-server.bat"
echo.
java %JAVA_OPTS% -cp "%DSPACE_CLASSPATH%" -Ddspace.log.init.disable=true -Dlog4j.configuration=log4j-handle-plugin.properties net.handle.server.Main %HANDLEDIR% >> "%LOGDIR%/handle-server.log"
java %JAVA_OPTS% -cp "%DSPACE_CLASSPATH%" -Ddspace.log.init.disable=true -Dlog4j2.configurationFile=log4j2-handle-plugin.xml net.handle.server.Main %HANDLEDIR% >> "%LOGDIR%/handle-server.log"

REM Clean up DSPACE_CLASSPATH variable
set DSPACE_CLASSPATH=
Expand Down
34 changes: 0 additions & 34 deletions dspace/config/log4j-handle-plugin.properties

This file was deleted.

Loading

0 comments on commit 76b54b3

Please sign in to comment.