项目调试技巧
服务端断点调试
IDEA下:
打断点,以Debug模式启动
F8向下执行一行
F7进入当前行方法内
F9程序直接向下执行,直到下一个断点为止
客户端断点调试
chrome下:
F10向下执行一行
F11进入方法内部
F8执行到下一个断点
设置日志级别,并将日志输出到不同的终端
控制台打印日志,如果在application.properties中配置可以设置日志的输出文件夹和等级
logging.level.com.gpnu.community=debug logging.file=d:/work/Data/nowcoder/community.log
public class LoggerTests { public static final Logger logger = LoggerFactory.getLogger(LoggerTests.class); @Test public void testLogger(){ logger.debug("debug level"); logger.info("info level"); logger.warn("warn level"); logger.error("error level"); } }
或者在Resource下添加logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration> <contextName>community</contextName> <property name="LOG_PATH" value="D:/work/Data"/> <property name="APPDIR" value="community"/> <!-- error file --> <appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${LOG_PATH}/${APPDIR}/log_error.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${LOG_PATH}/${APPDIR}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>5MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> <maxHistory>30</maxHistory> </rollingPolicy> <append>true</append> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern>%d %level [%thread] %logger{10} [%file:%line] %msg%n</pattern> <charset>utf-8</charset> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>error</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> </appender> <!-- warn file --> <appender name="FILE_WARN" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${LOG_PATH}/${APPDIR}/log_warn.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${LOG_PATH}/${APPDIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>5MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> <maxHistory>30</maxHistory> </rollingPolicy> <append>true</append> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern>%d %level [%thread] %logger{10} [%file:%line] %msg%n</pattern> <charset>utf-8</charset> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>warn</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> </appender> <!-- info file --> <appender name="FILE_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${LOG_PATH}/${APPDIR}/log_info.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${LOG_PATH}/${APPDIR}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>5MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> <maxHistory>30</maxHistory> </rollingPolicy> <append>true</append> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern>%d %level [%thread] %logger{10} [%file:%line] %msg%n</pattern> <charset>utf-8</charset> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>info</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> </appender> <!-- console --> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d %level [%thread] %logger{10} [%file:%line] %msg%n</pattern> <charset>utf-8</charset> </encoder> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>debug</level> </filter> </appender> <logger name="com.gpnu.community" level="debug"/> <root level="info"> <appender-ref ref="FILE_ERROR"/> <appender-ref ref="FILE_WARN"/> <appender-ref ref="FILE_INFO"/> <appender-ref ref="STDOUT"/> </root> </configuration>
版本控制
安装git
##本地版本控制
//查看git版本 git version //查看git配置信息 git config --list //初始化git git init //查看状态 git status //添加到git中 git add * //提交 git commit -m "要备注的xin"
远程仓库版本控制
//本地项目推送到远程仓库 //生成密钥 ssh-keygen -t rsa -C "邮箱" //推送已有项目 git remote add origin 远程仓库地址 git push -u origin master //克隆远程项目 git clone 远程项目地址