docker pull nacos/nacos-server
docker run -p 8848:8848 --name nacos \
--privileged=true --restart=always \
-e JVM_XMS=256m -e JVM_XMX=256m \
-e MODE=standalone -e PREFER_HOST_MODE=hostname \
-v /var/nacos/logs:/home/nacos/logs \
-v /var/nacos/conf:/home/nacos/conf \
-d nacos/nacos-server startup.sh -m standalone
查看nacos日志
docker logs nacos
可能会报错说没有nacos-logback.xml
在/var/nacos/conf/nacos-logback.xml中添加如下代码
注意第四行value=“/home/nacos/logs/logback.log”,其中引号内填写的和上面maven启动配置的需要一致
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="true" scanPeriod="1 seconds">
<contextName>logback</contextName>
<property name="log.path" value="/home/nacos/logs/logback.log" />
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<!-- <filter class="com.example.logback.filter.MyFilter" /> -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<encoder>
<pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<appender name="file"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}.%d{yyyy-MM-dd}.zip</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{36} [%file : %line] %msg%n
</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="console" />
<appender-ref ref="file" />
</root>
<logger name="com.example.logback" level="warn" />
</configuration>
重启docker-nacos
docker restart nacos
查看nacos日志文章来源:https://www.toymoban.com/news/detail-571182.html
docker logs nacos
文章来源地址https://www.toymoban.com/news/detail-571182.html
到了这里,关于使用docker安装nacos2.0,解决nacos-logback.xml (No such file or directory)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!