add: 启动日志

This commit is contained in:
xiongxiaoyang 2022-04-26 09:15:24 +08:00
parent 906e7762c9
commit 7395cf63e5
5 changed files with 50 additions and 3 deletions

View File

@ -1,12 +1,18 @@
package com.java2nb;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import java.net.InetAddress;
@EnableTransactionManagement
@ServletComponentScan
@ -15,9 +21,17 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
})
@EnableCaching
@Slf4j
public class AdminApplication {
public static void main(String[] args) {
SpringApplication.run(AdminApplication.class, args);
}
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return args -> {
log.info("项目启动啦,访问路径:{}", "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + ctx.getEnvironment().getProperty("server.port"));
};
}
}

View File

@ -36,3 +36,7 @@ mybatis:
typeAliasesPackage: com.java2nb.**.domain
#[弃用]配置缓存和session存储方式默认ehcache,可选redis,[弃用]调整至 spring cache typeshiro.用户权限sessionspring.cache通用
#[弃用]cacheType: ehcache
logging:
config: classpath:logback-boot.xml

View File

@ -24,7 +24,7 @@
<!-- RollingFileAppender滚动记录文件先将日志记录到指定文件当符合某个条件时将日志记录到其他文件 -->
<!-- 以下的大概意思是1.先按日期存日志日期变了将前一天的日志文件名重命名为XXX%日期%索引新的日志仍然是demo.log -->
<!-- 2.如果日期没有发生变化但是当前日志的文件大小超过1KB时对当前日志进行分割 重命名 -->
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>logs/debug.log</File>
<!-- rollingPolicy:当发生滚动时决定 RollingFileAppender 的行为涉及文件移动和重命名 -->
@ -52,11 +52,13 @@
<!-- 控制台输出日志级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
<!-- 指定项目中某个包当有日志操作行为时的日志记录级别 -->
<!-- com.maijinjie.springboot 为根包也就是只要是发生在这个根包下面的所有日志操作行为的权限都是DEBUG -->
<!-- 级别依次为从高到低FATAL > ERROR > WARN > INFO > DEBUG > TRACE -->
<logger name="com.java2nb" level="DEBUG" additivity="false">
<appender-ref ref="debug" />
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
</configuration>

View File

@ -1,12 +1,18 @@
package com.java2nb.novel;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.net.InetAddress;
/**
* @author Administrator
*/
@ -15,11 +21,19 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@ServletComponentScan
@MapperScan(basePackages = {"com.java2nb.novel.mapper"})
@Slf4j
public class CrawlNovelApplication {
public static void main(String[] args) {
SpringApplication.run(CrawlNovelApplication.class);
}
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return args -> {
log.info("项目启动啦,访问路径:{}", "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + ctx.getEnvironment().getProperty("server.port"));
};
}
}

View File

@ -1,11 +1,14 @@
package com.java2nb.novel;
import com.github.tobato.fastdfs.FdfsClientConfig;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.TaskScheduler;
@ -13,6 +16,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import java.net.InetAddress;
/**
* @author Administrator
*/
@ -23,15 +28,23 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@ServletComponentScan
@MapperScan(basePackages = {"com.java2nb.novel.mapper"})
@Import(FdfsClientConfig.class)
@Slf4j
public class FrontNovelApplication {
public static void main(String[] args) {
SpringApplication.run(FrontNovelApplication.class);
}
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return args -> {
log.info("项目启动啦,访问路径:{}", "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + ctx.getEnvironment().getProperty("server.port"));
};
}
/**
* 解决同一时间只能一个定时任务执行的问题
* */
*/
@Bean
public TaskScheduler taskScheduler() {
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();