Skip to content

Commit 6e2ee35

Browse files
authored
Enable morgan logging in azure deployed environments (#24066)
* enable morgan logging in azure deployed environments * include note about heroku logging
1 parent 53af500 commit 6e2ee35

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

middleware/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ import next from './next.js'
6464
import renderPage from './render-page.js'
6565
import assetPreprocessing from './asset-preprocessing.js'
6666

67-
const { NODE_ENV } = process.env
67+
const { DEPLOYMENT_ENV, NODE_ENV } = process.env
6868
const isDevelopment = NODE_ENV === 'development'
69+
const isAzureDeployment = DEPLOYMENT_ENV === 'azure'
6970
const isTest = NODE_ENV === 'test' || process.env.GITHUB_ACTIONS === 'true'
7071

7172
// Catch unhandled promise rejections and passing them to Express's error handler
@@ -79,8 +80,14 @@ export default function (app) {
7980
if (!isTest) app.use(timeout)
8081
app.use(abort)
8182

82-
// *** Development tools ***
83-
app.use(morgan('dev', { skip: (req, res) => !isDevelopment }))
83+
// *** Request logging ***
84+
// Enabled in development and azure deployed environments
85+
// Not enabled in Heroku because the Heroku router + papertrail already logs the request information
86+
app.use(
87+
morgan(isAzureDeployment ? 'combined' : 'dev', {
88+
skip: (req, res) => !(isDevelopment || isAzureDeployment),
89+
})
90+
)
8491

8592
// *** Observability ***
8693
if (process.env.DD_API_KEY) {

0 commit comments

Comments
 (0)