保存进度!
This commit is contained in:
		
							
								
								
									
										3
									
								
								code/java/DisasterWarning/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								code/java/DisasterWarning/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -134,3 +134,6 @@ $RECYCLE.BIN/
 | 
			
		||||
*.lnk
 | 
			
		||||
 | 
			
		||||
target/*
 | 
			
		||||
 | 
			
		||||
logs/*
 | 
			
		||||
logs
 | 
			
		||||
							
								
								
									
										10
									
								
								code/java/DisasterWarning/logging.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								code/java/DisasterWarning/logging.properties
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
 | 
			
		||||
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
 | 
			
		||||
 | 
			
		||||
.level = INFO
 | 
			
		||||
 | 
			
		||||
java.util.logging.FileHandler.pattern = ./logs/log_%u.log
 | 
			
		||||
java.util.logging.FileHandler.limit = 50000
 | 
			
		||||
java.util.logging.FileHandler.count = 1
 | 
			
		||||
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
 | 
			
		||||
java.util.logging.FileHandler.append = true;
 | 
			
		||||
@@ -84,6 +84,7 @@
 | 
			
		||||
            <plugin>
 | 
			
		||||
                <groupId>org.apache.maven.plugins</groupId>
 | 
			
		||||
                <artifactId>maven-surefire-plugin</artifactId>
 | 
			
		||||
                <version>3.0.0-M6</version>
 | 
			
		||||
                <configuration>
 | 
			
		||||
                    <skipTests>true</skipTests>
 | 
			
		||||
                </configuration>
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * @Author: Kane
 | 
			
		||||
 * @Date: 2022-04-22 10:53:49
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @LastEditTime: 2022-05-09 15:43:57
 | 
			
		||||
 * @LastEditTime: 2022-05-10 16:01:13
 | 
			
		||||
 * @FilePath: \DisasterWarning\src\main\java\AppMain.java
 | 
			
		||||
 * @Description: 和风天气预警推送厦门太保公众号主程序!
 | 
			
		||||
 * 
 | 
			
		||||
@@ -13,7 +13,7 @@ import com.cpic.xim.notify.disaster.QWeatherDisasterWarning;
 | 
			
		||||
import com.cpic.xim.notify.disaster.WeatherDisasterWarningGrabber;
 | 
			
		||||
import com.cpic.xim.wechat.officalAccount.sendMessage;
 | 
			
		||||
import com.cpic.xim.config.WeatherDisasterNotifyConfig;
 | 
			
		||||
 | 
			
		||||
import java.io.FileInputStream;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.sql.SQLException;
 | 
			
		||||
import java.util.Vector;
 | 
			
		||||
@@ -22,7 +22,7 @@ import java.util.logging.*;
 | 
			
		||||
 | 
			
		||||
public class AppMain
 | 
			
		||||
{
 | 
			
		||||
    private final static String LOG_FILE_PATH = "./app.log";
 | 
			
		||||
    // private final static String LOG_FILE_PATH = "./logs/app%u.log";
 | 
			
		||||
 | 
			
		||||
    public static void main( String[] args )
 | 
			
		||||
    {
 | 
			
		||||
@@ -79,6 +79,8 @@ public class AppMain
 | 
			
		||||
                // 判断是否有警报
 | 
			
		||||
                if ( warning.getWarning().isEmpty() == true)
 | 
			
		||||
                {
 | 
			
		||||
                    logger.log( Level.INFO, "查询{0}天气预警,无警报!。", new Object[]
 | 
			
		||||
                    { city.getCityName()} );
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@@ -125,18 +127,29 @@ public class AppMain
 | 
			
		||||
     */
 | 
			
		||||
    private static void setRootLogger() throws IOException
 | 
			
		||||
    {
 | 
			
		||||
        // Logger rootLogger = Logger.getLogger( "com.cpicxim" );
 | 
			
		||||
        // ConsoleHandler consoleHandler = new ConsoleHandler();
 | 
			
		||||
        // FileHandler fileHandler = new FileHandler( LOG_FILE_PATH );
 | 
			
		||||
        // SimpleFormatter formatter = new SimpleFormatter();
 | 
			
		||||
 | 
			
		||||
        // consoleHandler.setFormatter( formatter );
 | 
			
		||||
        // fileHandler.setFormatter( formatter );
 | 
			
		||||
 | 
			
		||||
        // rootLogger.addHandler( consoleHandler );
 | 
			
		||||
        // rootLogger.addHandler( fileHandler );
 | 
			
		||||
 | 
			
		||||
        // rootLogger.setUseParentHandlers( false );
 | 
			
		||||
        // rootLogger.setLevel( Level.ALL );
 | 
			
		||||
 | 
			
		||||
        LogManager logManager = LogManager.getLogManager();
 | 
			
		||||
        // 使用外部的配置文件。
 | 
			
		||||
        FileInputStream configFile = new FileInputStream( "./logging.properties" );
 | 
			
		||||
        // 使用jar中的配置文件。
 | 
			
		||||
        // InputStream configFile =
 | 
			
		||||
        // AppMain.class.getClassLoader().getResourceAsStream( "logging.properties" );
 | 
			
		||||
 | 
			
		||||
        logManager.readConfiguration( configFile );
 | 
			
		||||
 | 
			
		||||
        Logger rootLogger = Logger.getLogger( "com.cpicxim" );
 | 
			
		||||
        ConsoleHandler consoleHandler = new ConsoleHandler();
 | 
			
		||||
        FileHandler fileHandler = new FileHandler( LOG_FILE_PATH );
 | 
			
		||||
        SimpleFormatter formatter = new SimpleFormatter();
 | 
			
		||||
 | 
			
		||||
        consoleHandler.setFormatter( formatter );
 | 
			
		||||
        fileHandler.setFormatter( formatter );
 | 
			
		||||
 | 
			
		||||
        rootLogger.addHandler( consoleHandler );
 | 
			
		||||
        rootLogger.addHandler( fileHandler );
 | 
			
		||||
 | 
			
		||||
        rootLogger.setUseParentHandlers( false );
 | 
			
		||||
        rootLogger.setLevel( Level.ALL );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,10 @@
 | 
			
		||||
 | 
			
		||||
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
 | 
			
		||||
 | 
			
		||||
.level = INFO
 | 
			
		||||
 | 
			
		||||
java.util.logging.FileHandler.pattern = ./logs/log_%u.log
 | 
			
		||||
java.util.logging.FileHandler.limit = 50000
 | 
			
		||||
java.util.logging.FileHandler.count = 10
 | 
			
		||||
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
 | 
			
		||||
java.util.logging.FileHandler.append = true;
 | 
			
		||||
		Reference in New Issue
	
	Block a user