Skip to content

Commit

Permalink
🐛 Fix support of some DXP versions
Browse files Browse the repository at this point in the history
  • Loading branch information
slemarchand committed May 19, 2023
1 parent cc1c2f4 commit b21d550
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 147 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

![license](https://img.shields.io/github/license/slemarchand/lfr-log-config-auto-reloader?style=flat-square)

Watch log config file and automatically apply log config each time the file is modified, without the requirement of any restart of anything.
Watch any log config file and automatically apply log config each time the file is modified, without the requirement of any restart of anything.

## Compatibility

Liferay versions `7.1`, `7.2`, `7.3` and `7.4` are supported.
Liferay versions `7.1`, `7.2`, `7.3` and `7.4` are supported (both for `CE` and `DXP`).

## Installation

Expand All @@ -16,9 +16,22 @@ Get the `log-config-auto-reloader.jar` file from the [release page](https://gith

Go to Control `Panel > System Settings > Infrastructure > Log Config Auto Reloader` and edit the configuration.


Configuration parameters are:
*
*
*
*
*
*

Don't forget to submit the configuration form.

Alternatively, you can just the drop [this configuration file](https://github.com/slemarchand/lfr-log-config-auto-reloader/blob/main/configs/dev/osgi/configs/com.slemarchand.log.config.auto.reloader.internal.configuration.LogConfigAutoReloaderConfiguration.config) (usual config for local developement) into your `$LIFERAY_HOME/osgi/deploy` directory .
Alternatively, you can just the drop [this configuration file](https://github.com/slemarchand/lfr-log-config-auto-reloader/blob/main/configs/dev/osgi/configs/com.slemarchand.log.config.auto.reloader.internal.configuration.LogConfigAutoReloaderConfiguration.config) (usual config for local developement) into your `$LIFERAY_HOME/osgi/deploy` directory.

## Usage



## License

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

import java.io.File;
import java.io.IOException;
import java.util.Map;

import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Modified;
import org.osgi.service.component.annotations.Reference;

@Component(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Log4JUtilPortalImpl implements Log4JUtil {

@Activate
public void activate() {
_log.info("activate()");
_log.debug("activate()");
}

public void configureLog4J(URL url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.ReleaseInfo;

import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
Expand All @@ -12,32 +11,16 @@
@Component(service = Log4JUtilRegistrar.class, immediate = true)
public class Log4JUtilRegistrar {

public static final String VERSION_7_4_3_41 = "7.4.3.41";

@Activate
public void activate(BundleContext context) throws InvalidSyntaxException {

_log.debug("activate()");

// https://github.com/liferay/liferay-portal/blob/7.0.6-ga7/portal-kernel/src/com/liferay/portal/kernel/util/ReleaseInfo.java

String currentVersion = ReleaseInfo.getVersion(); // for example 7.4.3.75

boolean versionGreaterThanOrEqualTo74GA41 = new Version(currentVersion)
.greaterThanOrEqualTo(VERSION_7_4_3_41);

Log4JUtil service;

if(versionGreaterThanOrEqualTo74GA41) {

_log.info("Version dected is greater or equal to 7.4.3.41");

if(_isPortalImpl()) {
service = new Log4JUtilPortalImpl();

} else {

_log.info("Version dected is lesser or equal to 7.4.3.40");

service = new Log4JUtilPetraImpl();
}

Expand All @@ -46,6 +29,15 @@ public void activate(BundleContext context) throws InvalidSyntaxException {
_log.debug("Service registred: " + service.toString());
}

private boolean _isPortalImpl() {
try {
this.getClass().getClassLoader().loadClass("com.liferay.portal.log4j.Log4JUtil");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}

private Log _log = LogFactoryUtil.getLog(Log4JUtilRegistrar.class);


Expand Down

This file was deleted.

This file was deleted.

0 comments on commit b21d550

Please sign in to comment.