session-logger — GitHub Copilot hook: what it does, how to install
This GitHub Copilot hook records agent session start and end times, working directories, and user prompts into local JSON files for usage auditing.
.claude/settings.jsonWhat session-logger does
The hook monitors GitHub Copilot coding agent lifecycles by intercepting session launches, terminations, and prompt submissions. It stores structured JSON records directly on disk. Session milestones go to logs/copilot/session.log, while prompt inputs land in logs/copilot/prompts.log.
Three bash scripts handle the automation: log-session-start.sh, log-session-end.sh, and log-prompt.sh. Each operation runs with a 5-second timeout. The logger records timestamps alongside the current working directory. You can adjust verbosity with LOG_LEVEL or halt data collection entirely by setting SKIP_LOGGING=true.
Add logs/ to .gitignore immediately to prevent sensitive prompt logs from leaking into remote branches. The shell scripts also fail silently if they lack execution permissions via chmod +x.
What it helps with
- Audit coding agent activity on local machines
- Record session start and termination timestamps
- Store submitted developer prompts in structured JSON
- Disable event capturing during private work using
SKIP_LOGGING=true
Example prompts for the agent
- Refactor the authentication logic in
auth.ts - Run the unit test suite and fix failing tests
- Generate database migration scripts for the user table
How to install session-logger
Manually: put the files in place
.claude/settings.jsonThe hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json
Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command
Questions about session-logger
How to install session-logger in GitHub Copilot?
Copy the hook directory to .github/hooks/session-logger, create the log folder with mkdir -p logs/copilot, make scripts executable using chmod +x .github/hooks/session-logger/*.sh, and save the configuration or update .claude/settings.json.
What does session-logger do?
It captures GitHub Copilot agent events, logging start times, end times, working directories, and user prompts to local JSON files. This creates a clean audit trail for your coding sessions.
How to disable logging or restrict it to errors?
Set the SKIP_LOGGING=true environment variable to turn off tracking completely. To log errors only, set LOG_LEVEL=ERROR inside the hook environment configuration.
Source text
session-logger · MIT
---
name: 'Session Logger'
description: 'Logs all Copilot coding agent session activity for audit and analysis'
tags: ['logging', 'audit', 'analytics']
---
# Session Logger Hook
Comprehensive logging for GitHub Copilot coding agent sessions, tracking session starts, ends, and user prompts for audit trails and usage analytics.
## Overview
This hook provides detailed logging of Copilot coding agent activity:
- Session start/end times with working directory context
- User prompt submission events
- Configurable log levels
## Features
- **Session Tracking**: Log session start and end events
- **Prompt Logging**: Record when user prompts are submitted
- **Structured Logging**: JSON format for easy parsing
- **Privacy Aware**: Configurable to disable logging entirely
## Installation
1. Copy this hook folder to your repository's `.github/hooks/` directory:
```bash
cp -r hooks/session-logger .github/hooks/
```
2. Create the logs directory:
```bash
mkdir -p logs/copilot
```
3. Ensure scripts are executable:
```bash
chmod +x .github/hooks/session-logger/*.sh
```
4. Commit the hook configuration to your repository's default branch
## Log Format
Session events are written to `logs/copilot/session.log` and prompt events to `logs/copilot/prompts.log` in JSON format:
```json
{"timestamp":"2024-01-15T10:30:00Z","event":"sessionStart","cwd":"/workspace/project"}
{"timestamp":"2024-01-15T10:35:00Z","event":"sessionEnd"}
```
## Privacy & Security
- Add `logs/` to `.gitignore` to avoid committing session data
- Use `LOG_LEVEL=ERROR` to only log errors
- Set `SKIP_LOGGING=true` environment variable to disable
- Logs are stored locally only
```json
{
"version": 1,
"hooks": {
"sessionStart": [
{
"type": "command",
"bash": ".github/hooks/session-logger/log-session-start.sh",
"cwd": ".",
"timeoutSec": 5
}
],
"sessionEnd": [
{
"type": "command",
"bash": ".github/hooks/session-logger/log-session-end.sh",
"cwd": ".",
"timeoutSec": 5
}
],
"userPromptSubmitted": [
{
"type": "command",
"bash": ".github/hooks/session-logger/log-prompt.sh",
"cwd": ".",
"env": {
"LOG_LEVEL": "INFO"
},
"timeoutSec": 5
}
]
}
}
```
© github · MIT · github/awesome-copilot