WinCC V7 Tag Logging Not Archiving: Fix New Tag Persistence

David Krause13 min read
SCADA ConfigurationSiemensTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

1. Problem Overview

After adding new tag logging tags to an existing WinCC V7.0 project, the values appear in real time within a WinCC Online Trend Control or WinCC Online Table Control, but disappear as soon as the picture is closed. The runtime trend only renders in-memory buffered data while the picture is open; once the picture is unloaded, the buffer is discarded. Persistent historical values must be written to the Tag Logging archive database. When that write path is broken, the values are gone.

Two failure modes are typically observed in this scenario:

  • TLG database files corrupted or detached — SQL Server cannot append rows to the <projectname>Tlg.mdf / <projectname>Tlg.ldf pair, so all writes are silently dropped at runtime.
  • Tag value path broken (no PLC, no PLCSIM, no valid value) — the logging tag receives an initial value or a quality code other than 0xC0 (Good), and the configured acquisition cycle discards the value before it can be written to the archive.

Both cases surface as a working live display and an empty history.

Affected versions: WinCC V7.0, V7.0 SP1, V7.0 SP2, V7.0 SP3. The TLG/SQL architecture described here also applies to V7.2 through V7.5, but the directory layout and database engine differ in V8.0 (WinCC Unified).

2. WinCC V7 Tag Logging Architecture

WinCC V7 uses a Microsoft SQL Server instance to back every runtime database. The Tag Logging runtime writes measurement values to a per-project SQL database located inside the WinCC project directory.

Tag Logging database files
File Purpose Default location
<projectname>Tlg.mdf Primary data file — contains archive tag definitions, configured archives, and historical rows. <project>\<computer>\Tlg\
<projectname>Tlg.ldf SQL Server transaction log — required for write-ahead logging of every value inserted into the MDF. Same directory as MDF.
<projectname>Alg.mdf / .ldf Alarm Logging database (separate concern but same engine). <project>\<computer>\Alg\

The relevant runtime services are:

  • CCArchiveConn.exe — manages the connection between the WinCC data manager and the SQL Server instance.
  • CCArchiveServer.exe — the actual archive writer process. If this process is not running, no tag or alarm will be archived.
  • SQLSERVER.EXE — the underlying MSDE 2000 / SQL Server 2005/2008 Express instance that hosts the Tlg database.

The Tag Logging editor in WinCC Explorer (right-click Tag Logging → Open) is the engineering interface. At runtime, the same definitions are loaded into memory and the archive writer inserts new rows whenever a tag's acquisition cycle and archiving cycle produce a value whose quality is valid.

3. Root Cause Analysis

The most common causes, in order of frequency, for "newly added tag logging tags do not archive":

Failure matrix
# Root cause Symptom Diagnostic
1 TLG MDF/LDF files corrupted or detached (e.g., after a hard shutdown, disk-full event, or copy-paste of an opened project) All tags stop writing, not just new ones; GfxWin event log shows SQL errors Inspect CCArchiveServer.exe status; check Tlg.ldf size growth in RT
2 New tags added to a project whose SQL Server instance is still bound to the old TLG schema; archive metadata not refreshed Live display works in trend; history empty for new tags only Open Tag Logging editor, confirm new tags exist with correct cycle, save project, restart RT
3 No PLC connection (no PLCSIM, no physical S7 CPU reachable) Tag value is constant zero or initial value; quality code is 0x00 (Bad) WinCC Explorer → Tag Management → connection status icon; SIMATIC S7 PROTOCOL SUITE > TCP/IP > [connection] > Online
4 Archive tag was created but the trigger cycle does not match the tag update cycle Tag updates, but archiving cycle never elapses (e.g., 1 s tag on 24 h archive cycle) Compare Acquisition vs. Archiving cycle in the Tag Logging editor
5 Project activated from WinCC Explorer instead of from the closed project copy, leaving the project in a configuration-only state Tag Logging RT does not start; Start Tag Logging button is greyed out Right-click Tag Logging in WinCC Explorer → verify status text says "running"
6 WinCC Archive Configuration Tool import did not commit writes to the database; only the CSV file was updated New tags appear in the editor but missing from runtime archive list Open SQL Server Management Studio Express against \.\WinCC; check dbo.MSGTAG table

For this article's source scenario, the user confirmed no PLC connection and no PLCSIM. That means all new tags will receive quality code 0x00 or 0x1C (Bad - No Communication). The Tag Logging writer may still insert a row with a subnormal quality flag, but most Trend Control configurations suppress those rows. The fix path must address both the connection layer and the archive database integrity layer.

4. Prerequisites

Before opening the project and editing anything, confirm the following on the engineering station:

  1. WinCC V7.0 SP3 or later installed (V7.0 RT builds before SP1 are known to have Tag Logging issues fixed by Siemens Support Entry 44027453).
  2. Logged in as a member of the local SIMATIC HMI group; WinCC project directories require write access to the SQL data files.
  3. All WinCC runtime processes stopped. Use Stop Runtime in WinCC Explorer or kill the CCArchiveServer.exe process from Task Manager.
  4. The WinCC project directory backed up. The MDF/LDF recovery procedure below removes the archive files; the project is rebuilt from the in-project Tag Logging configuration.
  5. If the workstation has no physical PLC, S7-PLCSIM (matching the WinCC version) installed and licensed; otherwise install one or stub the connection with a simulated AS.

5. Step-by-Step Resolution

5.1 Verify the Tag Logging runtime state

  1. Open WinCC Explorer.
  2. Right-click Tag Logging in the navigation tree.
  3. Confirm the status line reads Runtime: started. If it reads Runtime: stopped, right-click and choose Start Tag Logging.
  4. Open the Diagnostics folder → Tools and launch APDiag to see live archive errors.

5.2 Validate every new tag in the editor

  1. Right-click Tag Logging → Open to launch the Tag Logging editor.
  2. Filter by the tag name prefix used for the new tags.
  3. For each row, verify the following columns:
Required Tag Logging editor parameters
Column Expected value Wrong setting that causes silent drop
Process tag Valid WinCC tag name (no red underline) Empty / unresolved internal alias
Acquisition cycle e.g., 500 ms, 1 s, 5 s, 1 min "On change" with no change → no row
Archiving cycle Multiple of acquisition cycle, e.g., 1 s, 10 s, 1 h 24 h on a fast-changing tag → no rows during a single test session
Archive Selected & set to "TagLoggingFast", "TagLoggingSlow", or a user-defined archive None / blank → tag exists but writes to no archive
Range limit / compression Disabled for initial test Hysteresis window that swallows real values
  1. Save the editor. WinCC will prompt to confirm the project change.

5.3 Regenerate the TLG database files

If the archive writer is reporting SQL errors, the MDF/LDF pair is suspect. WinCC can rebuild it from the in-project configuration:

  1. Stop WinCC Runtime completely.
  2. In Windows Explorer, navigate to <project_path>\<computer_name>\Tlg\.
  3. Move (do not delete yet) the following files to a backup folder:
    • <projectname>Tlg.mdf
    • <projectname>Tlg.ldf
  4. Confirm the directory is empty.
  5. Open the project in WinCC Explorer.
  6. Start the project. CCArchiveServer.exe will detect the missing database and recreate it using the saved archive configuration.
  7. Reopen Tag Logging editor and verify all archive tags (old and new) are still listed; if any are missing, they were not committed to the project before the rebuild and must be re-added.
Caution: Rebuilding the TLG database drops all previously archived historical data. Use this procedure only on development stations or after the user has confirmed the history is not required. In production environments, first attempt to attach the existing MDF in SQL Server Management Studio with sp_attach_db or a single-file CREATE DATABASE ... FOR ATTACH_REBUILD_LOG statement.

5.4 Restore the connection to the PLC or start PLCSIM

Tags without a live value are archived as initial value or rejected by the writer, depending on the archive configuration. The user's environment has no physical PLC and no PLCSIM; restore either:

  1. Option A — start PLCSIM:
    • Launch S7-PLCSIM and download the matching STEP 7 program to the simulated AS.
    • In PLCSIM, set the MPI/DP/TCP interface to PLCSIM(Internal).
    • Match the WinCC connection parameters to the same interface.
  2. Option B — install a simulated connection stub:
    • Create an internal WinCC tag that mirrors the structure of the real PLC tag.
    • Add a small C / VBScript inside the project startup that increments the internal tag on a 1 s timer.
    • Change the new logging tag's Process tag reference to point at the internal tag.
  3. Option C — use S7-PLCSIM with WinCC's TCP/IP channel:
    • Set the S7-PLCSIM interface to TCP/IP with IP 127.0.0.1, rack 0, slot 2.
    • In WinCC Tag Management > SIMATIC S7 PROTOCOL SUITE > TCP/IP, create a new connection to that address.

5.5 Restart runtime and verify archive growth

  1. Start Runtime.
  2. Open the trend picture. The trend should populate the live buffer.
  3. Close the trend picture.
  4. Wait at least one full archiving cycle plus 10 s.
  5. Inspect the file <project>\<computer>\Tlg\<projectname>Tlg.ldf — its size must have grown by at least a few kilobytes. This is the strongest evidence that the archive writer is actually committing rows.
  6. Reopen the trend picture; the historical curve must now extend backwards from the time the picture was closed.

6. Verification

Three independent checks confirm a successful fix:

  1. LDF growth check: The Tlg.ldf file size increases monotonically while Runtime is running and writing tags.
  2. SQL row count check: Connect with SQL Server Management Studio Express to \.\WinCC, then run:
    USE [<projectname>_Tlg]
    SELECT TOP 20 [Timestamp], [TagID], [RealValue], [Quality]
    FROM dbo.[<archive_name>]
    ORDER BY [Timestamp] DESC

    Substitute the actual archive table name (default: dbo.ARCHIVE_TLG_FAST or dbo.ARCHIVE_TLG_SLOW). New rows must appear with timestamps >= the time Runtime was started.

  3. WinCC Online Table Control reload: Open the trend/table picture, switch to Online mode, then to History mode. The history view must show data from before the picture was opened.

7. PLC Connection Validation in Detail

Tags that never receive a value are the most common silent failure. Use the following to validate the connection at the lowest level:

7.1 Channel diagnosis in Tag Management

  1. WinCC Explorer → Tag Management.
  2. Drill into SIMATIC S7 PROTOCOL SUITE > [selected channel] > [connection].
  3. Right-click the connection and choose Connection Status. Status must read OK and the icon in the tree must be green.
  4. Open the Properties of the connection and verify the rack/slot, partner IP, and TSAPs (for ISO-on-TCP) match the S7 configuration.

7.2 APDiag log path

APDiag writes per-tag acquisition and archiving status to <project>\<computer>\Diagnostics\. To enable detailed logging:

  1. Open WinCC Explorer → Computer → Properties → Graphics Runtime → APDiag.
  2. Tick Activate APDiag and set verbosity to Logging of errors and warnings at minimum.
  3. Restart Runtime.
  4. After the failure, inspect APDiagLog_<timestamp>.txt. Look for entries such as:
    Error: Tag <name> - acquisition value invalid, archive writer skipped
    Warning: Tag <name> - quality code 0x1C, not archived

7.3 Quality code reference

OPC quality codes relevant to WinCC Tag Logging
Code Meaning Archive behaviour
0xC0 Good Archived (subject to archiving cycle)
0x40 Uncertain Archived (optional flag in archive config)
0x00 Bad Rejected by writer
0x1C Bad - No Communication Rejected by writer
0x08 Bad - Not Connected Rejected by writer
0x10 Bad - Device Failure Rejected by writer

8. Archive Configuration Best Practices

  • Decouple acquisition and archiving cycles. Acquisition cycle < archiving cycle by a factor of 2 to 10 for proper averaging and compression. Example: acquire at 500 ms, archive at 5 s.
  • Use a single archive per physical process area. Multiple small archives cause the SQL Server to lock per-row contention, slowing writes on large projects.
  • Size the MDF/LDF for the data volume. For a project producing 1 000 values/s at 8 bytes per row, plan for 28.8 MB/hour of LDF growth in the default FULL recovery model; switch the TLG database to SIMPLE recovery to avoid runaway transaction logs.
  • Keep the project closed in the editor during runtime testing. Changes to the Tag Logging editor while Runtime is running will not propagate until the project is recompiled and Runtime is restarted.
  • Use the WinCC Archive Configuration Tool only for bulk import/export. Manual edits in the Tag Logging editor are written to the MDF directly; CSV imports require an explicit Apply followed by a Runtime restart to take effect.

9. Common Pitfalls and Edge Cases

  1. Project copy without regenerating the computer name. When a WinCC project is copied to a new machine, the <computer_name> subdirectory under the project still references the original machine. The Tag Logging runtime will fail to find the MDF because the path no longer resolves. Either rename the subdirectory to match the new computer or use the WinCC Project Migrator.
  2. Microsoft SQL Server Express size limit reached. SQL Server 2005/2008 Express caps at 4 GB. Once reached, the archive writer silently drops new rows. Monitor free space inside the Tlg database with the sp_spaceused stored procedure.
  3. Antivirus locking the MDF/LDF. Real-time AV scanning of *.mdf and *.ldf files causes intermittent SQL Server attach errors. Add the <project>\<computer>\Tlg and \Alg paths to the AV exclusion list.
  4. Clock drift between WinCC station and PLC. If the WinCC station clock drifts more than the configured tagging timestamp tolerance, the SQL writer may reject rows as out-of-order. Sync the engineering station with a NTP source and the PLC with the same source via S7 time-of-day synchronisation.
  5. Trend Control online buffer vs archive buffer. The Online Trend Control maintains its own in-memory ring buffer that is independent of the SQL archive. A working online display does not prove the archive is functioning; only a reload after closing the picture proves persistence.
  6. Tag Logging RT process killed by Windows user session. On Remote Desktop sessions that are not console sessions, CCArchiveServer.exe may receive a WM_ENDSESSION message on disconnect and terminate. Always run WinCC Runtime on the console or under a dedicated service account.

10. Reference: Tag Logging File Locations

Where to find Tag Logging files on a WinCC V7 station
Item Path
Project root C:\Program Files\Siemens\Automation\WinCC\WinCCProjects\<projectname>\
Tag Logging database <project>\<computername>\Tlg\
Alarm Logging database <project>\<computername>\Alg\
APDiag logs <project>\<computername>\Diagnostics\
WinCC Archive Configuration Tool CSV import template Export from Tag Logging → Tools → Archive Configuration
MSDE/SQL Server instance name \.\WinCC (default)

11. Upgrading to WinCC Unified

Projects that frequently suffer archive corruption on WinCC V7 benefit from migrating to WinCC Unified V20 Tag Logging (RT Unified). The Unified architecture moves the archive backend from MSDE/SQL Server Express to a SQLite-based store, eliminating the MDF/LDF detach problem entirely. The logging tag is created as a separate configuration object that references a process tag, and the data type is inherited from the source. Migration paths and compatibility notes are documented in the TIA Portal help referenced above.

12. Related Siemens Support Entries

Why do new WinCC V7 tags show live but never appear in history?

The Online Trend Control renders the in-memory buffer while the picture is open. Persistence requires the archive writer (CCArchiveServer.exe) to commit each value to the <projectname>Tlg.mdf database. If the MDF is detached, the writer is stopped, the tag has no valid quality, or the archiving cycle never elapses, no row is inserted and the trend is empty after the picture is closed.

Can I delete the TLG.LDF file to fix WinCC V7 archive problems?

Yes, but only when Runtime is stopped and only in conjunction with the matching MDF being regenerated. Moving both <projectname>Tlg.mdf and <projectname>Tlg.ldf aside and restarting WinCC Runtime causes the archive server to recreate a fresh database from the saved configuration. This drops historical data, so back up first.

Do tags need a live PLC connection to be archived?

Yes. Tags with quality code 0x00 (Bad), 0x08 (Bad - Not Connected), or 0x1C (Bad - No Communication) are rejected by the archive writer. Run S7-PLCSIM, connect a physical S7 CPU, or repoint the new logging tags at internal WinCC tags driven by a script.

What is the difference between the acquisition cycle and the archiving cycle?

The acquisition cycle is how often WinCC reads the process tag from the PLC. The archiving cycle is how often the buffered value is written to the SQL archive. The acquisition cycle must be equal to or faster than the archiving cycle; otherwise the archive never receives a value during a short Runtime test.

How do I confirm the archive is actually writing rows?

Check the file size of <project>\<computername>\Tlg\<projectname>Tlg.ldf while Runtime runs — it must grow. For row-level confirmation, query the archive table in SQL Server Management Studio Express with SELECT TOP 20 * FROM dbo.[ARCHIVE_TLG_FAST] ORDER BY Timestamp DESC against the \.\WinCC instance.

Back to blog