Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature internal 29 unique logging #549

Merged
merged 18 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions java/edu/ucar/metviewer/MVBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;



public class MVBatch {

private static final Logger logger = LogManager.getLogger(MVBatch.class);
Expand Down Expand Up @@ -450,7 +448,6 @@ public static void main(String[] argv) throws Exception {
logger.info("---- MVBatch Done by user " + username + " ----");

logger.info("Total execution time " + stopWatch.getFormattedTotalDuration());

}

}
2 changes: 1 addition & 1 deletion java/edu/ucar/metviewer/MVLoad.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.logging.log4j.*;
import org.apache.logging.log4j.io.IoBuilder;


public class MVLoad {

private static final Logger logger = LogManager.getLogger("MVLoad");
Expand Down Expand Up @@ -69,7 +70,6 @@ private MVLoad() {
public static void main(String[] argv) {

logger.info("---- MVLoad ----\n");

try {

// parse the input arguments
Expand Down
1 change: 1 addition & 0 deletions java/edu/ucar/metviewer/MVServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ private String getAvailableResults(String showAll) throws ParserConfigurationExc
@Override
public void init() {
logger.debug("init() - loading properties...");

try {
ResourceBundle bundle = ResourceBundle.getBundle("mvservlet");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;

import java.io.*;
import java.sql.*;
import java.text.SimpleDateFormat;
Expand Down
9 changes: 4 additions & 5 deletions java/edu/ucar/metviewer/db/mysql/MysqlDatabaseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import edu.ucar.metviewer.db.DatabaseManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import org.apache.tomcat.jdbc.pool.DataSource;
import org.apache.tomcat.jdbc.pool.PoolConfiguration;
import org.apache.tomcat.jdbc.pool.PoolProperties;
Expand All @@ -40,7 +39,6 @@
public class MysqlDatabaseManager extends DatabaseManager {

private static final Logger logger = LogManager.getLogger(MysqlDatabaseManager.class);

protected static Map<String, String> listDB = new TreeMap<>();
protected static Map<String, List<String>> groupToDatabases = new HashMap<>();
private static String DATE_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss";
Expand All @@ -57,6 +55,8 @@ public class MysqlDatabaseManager extends DatabaseManager {

public MysqlDatabaseManager(DatabaseInfo databaseInfo, String password) {
super(databaseInfo);
// Add hostname to the ThreadContext for logging

String jdbcUrl = getJdbcUrl(databaseInfo.getHost(), databaseInfo.getDbName());
PoolConfiguration configurationToUse = new PoolProperties();
configurationToUse.setUrl(jdbcUrl);
Expand Down Expand Up @@ -85,15 +85,14 @@ public MysqlDatabaseManager(DatabaseInfo databaseInfo, String password) {

dataSource = new DataSource();
dataSource.setPoolProperties(configurationToUse);



boolean updateGroups = false;
if (databaseInfo.getDbName() == null) {
updateGroups = true;
}
initDBList(updateGroups);
}

public synchronized String formatDate(Date date) {
return DATE_FORMAT.format(date.getTime());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
Expand Down Expand Up @@ -82,7 +81,6 @@ public class MysqlLoadDatabaseManager extends MysqlDatabaseManager implements Lo
public MysqlLoadDatabaseManager(
DatabaseInfo databaseInfo, String password) throws DatabaseException {
super(databaseInfo, password);

tableToInsert = new HashMap<>();
tableToInsert.put("line_data_fho", "INSERT INTO line_data_fho VALUES (?,?,?,?,?,?,?,?,?,?,?,?,"
+ "?,?)");//14
Expand Down
3 changes: 2 additions & 1 deletion java/edu/ucar/metviewer/log4j2.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<!-- Suggested code may be subject to a license. Learn more: ~LicenseLog:251802877. -->
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">

<Appenders>
<Console name="appLog" target="SYSTEM_OUT">
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%L}{blue}] [%style{%M}{bright,blue}] %style{%C{1.}}{bright,yellow}: \r\n%msg%n%throwable\r\n" />
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%L}{blue}] [%style{%M}{bright,blue}] %style{%C{1.}}{bright,yellow} %style{METviewer}{bright,green} %style{[%X{hostName}]}{bright,red} %msg%n%throwable%n" />
</Console>
</Appenders>

Expand Down
6 changes: 3 additions & 3 deletions webapp/metviewer/WEB-INF/classes/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%L}{blue}] [%style{%M}{bright,blue}] %style{%C{1.}}{bright,yellow} %style{METviewer}{bright,green} %style{[${env:HOSTNAME:-None}]}{bright,red} %msg%n%throwable%n" />
</Console>

<File name="RollingFile" fileName="/opt/vxwww/tomcat/logs/mvservlet.log" append="true">
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%L}{blue}] [%style{%M}{bright,blue}] %style{%C{1.}}{bright,yellow} %style{METviewer}{bright,green} %style{[${env:HOSTNAME:-None}]}{bright,red} %msg%n%throwable%n" />
</File>
</Appenders>

Expand Down
8 changes: 4 additions & 4 deletions webapp/metviewer/WEB-INF/classes/log4j2.xml.orig
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%L}{blue}] [%style{%M}{bright,blue}] %style{%C{1.}}{bright,yellow} %style{METviewer}{bright,green} %style{[${env:HOSTNAME:-None}]}{bright,red} %msg%n%throwable%n" />
</Console>

<File name="RollingFile" fileName="/opt/vxwww/tomcat/logs/mvservlet.log" append="true">
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%L}{blue}] [%style{%M}{bright,blue}] %style{%C{1.}}{bright,yellow} %style{METviewer}{bright,green} %style{[${env:HOSTNAME:-None}]}{bright,red} %msg%n%throwable%n" />
</File>
</Appenders>

Expand All @@ -18,4 +18,4 @@
<AppenderRef ref="RollingFile"/>
</Root>
</Loggers>
</Configuration>
</Configuration>