Compare commits

...

2 commits

Author SHA1 Message Date
62815f6d1e Migrated to Log4j2. 2021-12-29 01:00:20 +01:00
d5c67afb64 Improved generic metric display. 2021-12-24 17:38:30 +01:00
27 changed files with 120 additions and 76 deletions

View file

@ -11,11 +11,8 @@
<classpathentry kind="lib" path="lib/commons-codec-1.8.jar" sourcepath="lib/commons-codec-1.8-sources.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="lib/mysql-jdbc-5.0.8.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-1.2.17.jar" sourcepath="lib/Logs/log4j-1.2.17-source.zip"/>
<classpathentry kind="lib" path="lib/UnitTesting/hamcrest-core-1.3.jar" sourcepath="lib/UnitTesting/hamcrest-core-1.3-sources.jar"/>
<classpathentry kind="lib" path="lib/hsqldb-2.3.0.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.25.jar" sourcepath="lib/Logs/slf4j-api-1.7.25-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-log4j12-1.7.25.jar" sourcepath="lib/Logs/slf4j-log4j12-1.7.25-sources.jar"/>
<classpathentry kind="lib" path="lib/UnitTesting/junit-4.12.jar" sourcepath="lib/UnitTesting/junit-4.12-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-cli-1.4.jar" sourcepath="lib/commons-cli-1.4-sources.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.7.jar" sourcepath="lib/commons-io-2.7-sources.jar"/>
@ -27,5 +24,9 @@
<classpathentry kind="lib" path="lib/jOpenDocument-1.3.jar" sourcepath="lib/jOpenDocument-src-1.3.zip"/>
<classpathentry kind="lib" path="lib/threeten-extra-1.5.0.jar" sourcepath="lib/threeten-extra-1.5.0-sources.jar"/>
<classpathentry kind="lib" path="lib/devinsy-strings-0.11.4.jar" sourcepath="lib/devinsy-strings-0.11.4-sources.zip"/>
<classpathentry kind="lib" path="lib/Logs/log4j-api-2.17.0.jar" sourcepath="lib/Logs/log4j-api-2.17.0-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-core-2.17.0.jar" sourcepath="lib/Logs/log4j-core-2.17.0-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/log4j-slf4j-impl-2.17.0.jar" sourcepath="lib/Logs/log4j-slf4j-impl-2.17.0-sources.jar"/>
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.32.jar" sourcepath="lib/Logs/slf4j-api-1.7.32-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,13 +0,0 @@
# Log configuration
# #################
# priority setting: DEBUG < INFO < WARN < ERROR
log4j.rootLogger = INFO, console
log4j.logger.fr.devinsy.statoolinfos = INFO
log4j.logger.fr.devinsy.xidyn = WARN
#--
log4j.appender.console = org.apache.log4j.ConsoleAppender
log4j.appender.console.layout = org.apache.log4j.PatternLayout
#log4j.appender.console.layout.ConversionPattern = %d{ISO8601} - StatoolInfos [%-5p] %34.34c.%25M - %m%n
log4j.appender.console.layout.ConversionPattern = %m%n

26
log4j2.properties Normal file
View file

@ -0,0 +1,26 @@
# Log configuration
# #################
# priority setting: DEBUG < INFO < WARN < ERROR
dest = err
name = Log4j2PropertiesConfig
status = ERROR
# Appenders settings.
appenders = console
appender.console.type = Console
appender.console.name = LogToConsole
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %m%n
# Logger settings.
rootLogger.level = INFO
rootLogger.appenderRefs = a
rootLogger.appenderRef.a.ref = LogToConsole
logger.statoolinfos.name = fr.devinsy.statoolinfos
logger.statoolinfos.level = INFO
logger.xidyn.name = fr.devinsy.xidyn
logger.xidyn.level = WARN

View file

@ -1,21 +0,0 @@
# Log configuration
# #################
# priority setting: DEBUG < INFO < WARN < ERROR
log4j.rootLogger = INFO, stdout, LogWriter
log4j.logger.fr.devinsy.statoolinfos = INFO
log4j.logger.fr.devinsy.xidyn = INFO
#--
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = %m%n
#--
log4j.appender.LogWriter = org.apache.log4j.RollingFileAppender
log4j.appender.LogWriter.File = /srv/StatoolInfos/tatoolinfos.log
log4j.appender.LogWriter.MaxFileSize = 100000KB
log4j.appender.LogWriter.MaxBackupIndex = 5
log4j.appender.LogWriter.layout = org.apache.log4j.PatternLayout
log4j.appender.LogWriter.layout.ConversionPattern = %d{ISO8601} - InfosStatool [%-5p] %34.34c.%-25M - %m%n

View file

@ -0,0 +1,26 @@
# Log configuration
# #################
# priority setting: DEBUG < INFO < WARN < ERROR
dest = err
name = Log4j2PropertiesConfig
status = ERROR
# Appenders settings.
appenders = console
appender.console.type = Console
appender.console.name = LogToConsole
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %m%n
# Logger settings.
rootLogger.level = INFO
rootLogger.appenderRefs = a
rootLogger.appenderRef.a.ref = LogToConsole
logger.statoolinfos.name = fr.devinsy.statoolinfos
logger.statoolinfos.level = INFO
logger.xidyn.name = fr.devinsy.xidyn
logger.xidyn.level = WARN

View file

@ -20,11 +20,9 @@ package fr.devinsy.statoolinfos;
import java.io.File;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.EnhancedPatternLayout;
import org.apache.log4j.Level;
import org.apache.log4j.PropertyConfigurator;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -56,14 +54,14 @@ public final class StatoolInfosLauncher
File loggerConfig = new File("log4j.properties");
if (loggerConfig.exists())
{
PropertyConfigurator.configure(loggerConfig.getAbsolutePath());
Configurator.initialize(null, loggerConfig.getAbsolutePath());
logger.info("Dedicated log configuration done.");
logger.info("Configuration file was found in [{}].", loggerConfig.getAbsoluteFile());
}
else
{
BasicConfigurator.configure(new ConsoleAppender(new EnhancedPatternLayout("%m%n")));
org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO);
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.INFO);
}
// Run.

View file

@ -487,7 +487,7 @@ public class Service extends PathPropertyList
{
long result;
MonthValues values = getMetricMonthValues("metrics.users.count");
MonthValues values = getMetricMonthValues("metrics.service.users");
values = values.extract(YearMonth.now().minusMonths(1), YearMonth.now().minusMonths(1));
@ -506,7 +506,7 @@ public class Service extends PathPropertyList
{
long result;
MonthValues values = getMetricMonthValues("metrics.http.visits.visitors");
MonthValues values = getMetricMonthValues("metrics.http.visits.humans");
values = values.extract(YearMonth.now().minusMonths(1), YearMonth.now().minusMonths(1));

View file

@ -69,9 +69,15 @@ public class FederationMetricGenericPage
data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.GENERIC, view, period));
//
FederationMetricHtmlizer.htmlize(data, "users.count", federation, view, period, "metrics.users.count", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "database.bytes", federation, view, period, "metrics.database.bytes", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "files.bytes", federation, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.users", federation, view, period, "metrics.service.users", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.accounts.combo", federation, view, period, "Accounts + active", "metrics.service.accounts", ChartColor.YELLOW,
"metrics.service.accounts.active", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.accounts", federation, view, period, "metrics.service.accounts", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.accounts.active", federation, view, period, "metrics.service.accounts.active", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.database.bytes", federation, view, period, "metrics.service.database.bytes", ChartColor.GREEN);
FederationMetricHtmlizer.htmlize(data, "graphic.files.bytes", federation, view, period, "metrics.service.files.bytes", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString();

View file

@ -70,12 +70,17 @@ public class OrganizationMetricGenericPage
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.GENERIC, view, period));
//
OrganizationMetricHtmlizer.htmlize(data, "users.count", organization, view, period, "metrics.users.count", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "database.bytes", organization, view, period, "metrics.database.bytes", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "files.bytes", organization, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.users", organization, view, period, "metrics.service.users", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.accounts.combo", organization, view, period, "Accounts + active", "metrics.service.accounts", ChartColor.YELLOW,
"metrics.service.accounts.active", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.accounts", organization, view, period, "metrics.service.accounts", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.accounts.active", organization, view, period, "metrics.service.accounts.active", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.database.bytes", organization, view, period, "metrics.service.database.bytes", ChartColor.GREEN);
OrganizationMetricHtmlizer.htmlize(data, "graphic.files.bytes", organization, view, period, "metrics.service.files.bytes", ChartColor.GREEN);
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString();
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml");

View file

@ -70,9 +70,21 @@ public class ServiceMetricGenericPage
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.GENERIC, view, period));
//
ServiceMetricHtmlizer.htmlize(data, "users.count", service, view, period, "metrics.users.count", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "database.bytes", service, view, period, "metrics.database.bytes", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "files.bytes", service, view, period, "metrics.http.visits.visitors", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.users", service, view, period, "metrics.service.users", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.accounts.combo", service, view, period, "Accounts + active", "metrics.service.accounts", ChartColor.YELLOW,
"metrics.service.accounts.active", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.accounts", service, view, period, "metrics.service.accounts", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.accounts.active", service, view, period, "metrics.service.accounts.active", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.database.bytes", service, view, period, "metrics.service.database.bytes", ChartColor.GREEN);
ServiceMetricHtmlizer.htmlize(data, "graphic.files.bytes", service, view, period, "metrics.service.files.bytes", ChartColor.GREEN);
// metrics.moderation.accounts.reported.* =
// metrics.moderation.accounts.sanctioned.* =
// metrics.moderation.accounts.disabled.* =
// metrics.moderation.accounts.silenced.* =
// metrics.moderation.accounts.cancelled.* =
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString();

View file

@ -16,11 +16,15 @@
<div id="metricMenuView" />
<div id="charts" style="display: block;">
<h2>Utilisateurs</h2>
<div id="users.count" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
<div id="graphic.users" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
<br/>
<div id="graphic.accounts.combo" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
<div id="graphic.accounts" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
<div id="graphic.accounts.active" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
<h2>Données</h2>
<div id="database.bytes" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
<div id="files.bytes" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
<div id="graphic.database.bytes" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
<div id="graphic.files.bytes" style="width: 450px; height: 300px; display: inline-block; border: 1px solid #e7e7e7;"/>
</div>
</div>
</body>

View file

@ -18,9 +18,9 @@
*/
package fr.devinsy.statoolinfos.core;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -60,7 +60,7 @@ public class StatoolInfosTest
@BeforeClass
public static void beforeClass() throws StatoolInfosException
{
BasicConfigurator.configure();
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.DEBUG);
}
}

View file

@ -18,9 +18,9 @@
*/
package fr.devinsy.statoolinfos.metrics.http;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@ -72,7 +72,7 @@ public class UserAgentBotDetectorTest
@BeforeClass
public static void beforeClass() throws StatoolInfosException
{
BasicConfigurator.configure();
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.DEBUG);
}
}

View file

@ -20,9 +20,9 @@ package fr.devinsy.statoolinfos.metrics.http;
import java.time.LocalDateTime;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@ -271,7 +271,7 @@ public class VisitCountersTest
@BeforeClass
public static void beforeClass() throws StatoolInfosException
{
BasicConfigurator.configure();
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.DEBUG);
}
}