Docker Community Forums

Share and learn in the Docker community.

Nlog with docker-compose.yml

Hi,

Any suggestions on how could we attach the NLog.config to a docker-compose.yml file so that it generates a “NLog_Internal.txt” on the host machine and we can see all the application logs in that file?

I have already tried creating an ASP.NET Core application with “NLog.config” and having only “NLog.Web.AspNetCore” package but still doesn’t work.

Thanks,
Kush Mishra

To add, the docker-compose.yml I am presently using, looks like the following:

version: ‘3.4’

networks:
myapp-network:
driver: bridge

services:
myapp:
image: myapp:latest
depends_on:
- “postgres_image”
build:
context: .
dockerfile: Dockerfile
env_file: .env
ports:
- “5000:80”
volumes:
- myapp_logsvolume: /data/logs/app
environment:
ISDOCKER: ${ISDOCKER}
networks:
- myapp-network

postgres_image:
image: postgres:latest
ports:
- “5432:5432”
restart: always
volumes:
- postgres_datavolume:/var/lib/postgresql/data
- postgres_backupvolume:/backups
environment:
POSTGRES_USER: {POSTGRESUSER} POSTGRES_PASSWORD: {POSTGRESPWD}
POSTGRES_DB: ${POSTGRESDB}
networks:
- myapp-network

volumes:
myapp_logsvolume:
postgres_datavolume:
postgres_backupvolume: